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.
91 lines
2.6 KiB
91 lines
2.6 KiB
<template>
|
|
<!-- 自定义表单 -->
|
|
<div class="inintatesProject">
|
|
<div style="display: flex; justify-content: center; align-items: center; height: 100px;">
|
|
<h1 style="font-weight: bold; font-size: 20px; color: black;">项目入库申请表</h1>
|
|
</div>
|
|
<BasicForm @register="registerForm" @submit="handleSubmit" />
|
|
</div>
|
|
</template>
|
|
<script lang="ts" name="initiatesProjects" setup>
|
|
import { onMounted } from 'vue'
|
|
import { useForm, BasicForm } from '@/components/Form';
|
|
import { formSchemas } from '../projectInfo/projectInfo.data';
|
|
import { submitProjectInfo } from './initiatesProjects.api'
|
|
import { Modal } from 'ant-design-vue';
|
|
import { queryProjectInfoById } from '@/views/projectLib/projectInfo/projectInfo.api'
|
|
|
|
let dataTo = defineProps(["projectid"])
|
|
let emit = defineEmits(["close"])
|
|
onMounted(async () => {
|
|
if (dataTo.projectid) {
|
|
let param: any = {
|
|
projectid: dataTo.projectid
|
|
}
|
|
let res = await queryProjectInfoById(param)
|
|
console.log("结果是", res)
|
|
setFieldsValue(res)
|
|
}
|
|
})
|
|
|
|
|
|
|
|
const [registerForm, { validate, setFieldsValue, getFieldsValue }] = useForm({
|
|
//注册表单列
|
|
schemas: formSchemas,
|
|
//回车提交
|
|
// autoSubmitOnEnter: true,
|
|
// //不显示重置按钮
|
|
//自定义提交按钮文本和图标
|
|
resetButtonOptions: { text: '取消' },
|
|
|
|
submitButtonOptions: { text: '提交' },
|
|
//查询列占比 24代表一行 取值范围 0-24
|
|
resetFunc: customResetFunc,
|
|
actionColOptions: { span: 14 },
|
|
labelCol: { style: { width: '120px' } },
|
|
wrapperCol: { style: { width: 'auto' } },
|
|
});
|
|
|
|
async function customResetFunc() {
|
|
emit("close")
|
|
}
|
|
async function handleSubmit() {
|
|
if (await validate()) {
|
|
Modal.confirm({
|
|
title: '提示窗口',
|
|
content: '是否提交入库申请表?',
|
|
okText: '确认',
|
|
cancelText: '取消',
|
|
onOk: async () => {
|
|
let datas = await getFieldsValue()
|
|
console.log("datas", datas)
|
|
submitProjectInfo(datas).then(() => {
|
|
let datasnull = clearObjectValues(datas)
|
|
setFieldsValue(datasnull)
|
|
emit("close")
|
|
})
|
|
|
|
},
|
|
});
|
|
console.log("我提交了")
|
|
} else {
|
|
console.log("未完成")
|
|
|
|
}
|
|
}
|
|
function clearObjectValues(obj) {
|
|
for (let key in obj) {
|
|
if (obj.hasOwnProperty(key)) {
|
|
obj[key] = null
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
</script>
|
|
<style scoped>
|
|
.inintatesProject {
|
|
padding-left: 40px;
|
|
padding-right: 40px
|
|
}
|
|
</style>
|