Files
laws-sinotruk-client/src/views/enterpriseStandardLibrary/standard/modules/EnterpriseStandardModal.vue
T
2023-09-13 12:01:30 +08:00

108 lines
2.7 KiB
Vue

<template>
<a-drawer
:title="title"
:width="width"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
:maskClosable="false"
class="custom-drawer-style"
>
<a-spin :spinning="confirmLoading" style="width: 100%;height:100%">
<div class="custom-drawer-style-scroll">
<add-form ref="addForm"
:get-form-func="getFormFunc"
:get-document-info-func="getDocumentInfoFunc"
@submitFormData="submitFormData" />
</div>
<div class="custom-drawer-style-bottom-btn">
<a-button @click="handleOk" type="primary" style="margin-bottom: 0;">
{{ $t('preservation') }}
</a-button>
<a-button @click="handleCancel" style="margin-bottom: 0;">{{ $t('close') }}</a-button>
</div>
</a-spin>
</a-drawer>
</template>
<script>
import '@assets/less/common.less'
import AddForm from '@/components/customField/AddForm'
import { getEnterpriseStandardAddForm, getEnterpriseStandardInfoById } from '@/api/enterpriseStandardLibraryApi'
import { postAction } from '@/api/manage'
export default {
name: 'EnterpriseStandardModal',
components: { AddForm },
data () {
return {
visible: false,
title: '',
width: 800,
// 存储表单的数据
form: {},
confirmLoading: false,
getFormFunc: getEnterpriseStandardAddForm,
getDocumentInfoFunc: getEnterpriseStandardInfoById,
url: {
add: '/laws/standard/enterprise/commonAdd',
edit: '/laws/standard/enterprise/commonEdit'
}
}
},
methods: {
add () {
this.visible = true
this.$nextTick(() => {
this.$refs.addForm.add()
})
},
edit (record) {
this.visible = true
this.$nextTick(() => {
this.$refs.addForm.edit(record)
})
},
handleOk () {
this.$refs.addForm.submit()
},
// 表单提交的回调,获取表单数据
submitFormData (formInline) {
this.confirmLoading = true
let url = ''
if (formInline.id) {
url = this.url.edit
} else {
url = this.url.add
}
postAction(url, formInline).then((res) => {
if (res.success) {
this.$message.success(this.$t('operationSuccessful'))
if (this.formInline.id) {
this.$emit('ok')
} else {
this.$emit('ok')
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
},
handleCancel () {
this.close()
},
close () {
this.visible = false
this.$refs.addForm.clearValidate()
}
}
}
</script>
<style scoped>
</style>