数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.5 KiB

<!--
@ 作者: 秦东
@ 时间: 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----------->", formEl.value)
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()
})
const changeKeyVal = (key:any,val:any,type:any,attribute:any) => {
}
</script>
<template>
<el-card v-loading="state.loading" shadow="never" style="min-height: 300px">
<ak-form
ref="formEl"
:form-data="state.formData"
:type="formType"
:dict="state.dict"
request-url="getFormContent"
add-url="saveFormContent"
edit-url="editFormContent"
:before-submit="beforeSubmit"
:after-submit="afterSubmit"
:change-key-val="changeKeyVal"
/>
</el-card>
</template>
<style lang='scss' scoped>
</style>