|
|
|
|
<!--
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-09-01 16:16:54
|
|
|
|
|
@ 备注:
|
|
|
|
|
-->
|
|
|
|
|
<script lang='ts' setup>
|
|
|
|
|
import { ref, reactive, onMounted, computed, nextTick } from 'vue'
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
import {
|
|
|
|
|
json2string,
|
|
|
|
|
objToStringify,
|
|
|
|
|
string2json,
|
|
|
|
|
stringToObj
|
|
|
|
|
} from '@/utils/DesignForm/form'
|
|
|
|
|
import { useLayoutStore } from '@/store/DesignForm/layout'
|
|
|
|
|
import { getRequest } from '@/api/DesignForm'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '@/assets/scss/element-var.scss'
|
|
|
|
|
import '@/assets/scss/index.scss'
|
|
|
|
|
import '@/assets/iconfont/iconfont.css'
|
|
|
|
|
import 'element-plus/dist/index.css'
|
|
|
|
|
import {
|
|
|
|
|
constGetControlByName,
|
|
|
|
|
constSetFormOptions,
|
|
|
|
|
constFormBtnEvent,
|
|
|
|
|
constControlChange,
|
|
|
|
|
constFormProps,
|
|
|
|
|
appendOrRemoveStyle
|
|
|
|
|
} from '@/api/DesignForm/utils'
|
|
|
|
|
|
|
|
|
|
const layoutStore = useLayoutStore()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const formEl = ref()
|
|
|
|
|
const state = reactive({
|
|
|
|
|
formData: {
|
|
|
|
|
list: [],
|
|
|
|
|
form: {},
|
|
|
|
|
config: {}
|
|
|
|
|
},
|
|
|
|
|
dict: {},
|
|
|
|
|
formId: 25,
|
|
|
|
|
id: 1,
|
|
|
|
|
loading: true
|
|
|
|
|
})
|
|
|
|
|
const formType = computed(() => {
|
|
|
|
|
// 带有参数id为编辑状态
|
|
|
|
|
if (true) {
|
|
|
|
|
return 2
|
|
|
|
|
} else {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const getFormData = () => {
|
|
|
|
|
if (!state.formId) {
|
|
|
|
|
ElMessage.error('非法操作.')
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
const params = {
|
|
|
|
|
id: state.formId
|
|
|
|
|
}
|
|
|
|
|
getRequest('designById', params)
|
|
|
|
|
.then((res: any) => {
|
|
|
|
|
const result = res.data
|
|
|
|
|
state.formData = stringToObj(result.data)
|
|
|
|
|
state.dict = string2json(result.dict)
|
|
|
|
|
formEl.value.getData({ formId: state.formId, id: 1})
|
|
|
|
|
console.log("res----------->", res.data)
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
state.loading = false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.catch((res: any) => {
|
|
|
|
|
state.loading = false
|
|
|
|
|
ElMessage.error(res.message || '非法操作..')
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const beforeSubmit = (params: any) => {
|
|
|
|
|
params.formId = state.formId
|
|
|
|
|
params.id = 1
|
|
|
|
|
return params
|
|
|
|
|
}
|
|
|
|
|
const afterSubmit = (type: string) => {
|
|
|
|
|
if (type === 'success') {
|
|
|
|
|
router.go(-1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getFormData()
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<el-card v-loading="state.loading" shadow="never" style="min-height: 300px">
|
|
|
|
|
<ak-form
|
|
|
|
|
ref="formEl"
|
|
|
|
|
:formData="state.formData"
|
|
|
|
|
:type="formType"
|
|
|
|
|
:dict="state.dict"
|
|
|
|
|
requestUrl="getFormContent"
|
|
|
|
|
addUrl="saveFormContent"
|
|
|
|
|
editUrl="editFormContent"
|
|
|
|
|
:beforeSubmit="beforeSubmit"
|
|
|
|
|
:afterSubmit="afterSubmit"
|
|
|
|
|
/>
|
|
|
|
|
</el-card>
|
|
|
|
|
</template>
|
|
|
|
|
<style lang='scss' scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|