Files
laws-sinotruk-client/src/views/standardRegulationLibrary/overseasStandard/modules/OverseasStandardModal.vue
T

99 lines
2.4 KiB
Vue

<template>
<a-drawer
:title="title"
:width="width"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
:maskClosable="false"
style="height: 100%;overflow: auto;"
>
<a-spin :spinning="confirmLoading" style="width: 100%;height:100%">
<div class="drawer-container">
<add-form ref="addForm" :url="url" @submitFormData="submitFormData"></add-form>
</div>
<div class="drawer-footer">
<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 AddForm from '../../../../components/customField/AddForm.vue'
import { postAction } from '../../../../api/manage'
export default {
name: 'OverseasStandardModal',
components: { AddForm },
data () {
return {
visible: false,
title: '',
width: 800,
// 存储表单的数据
form: {},
confirmLoading: false,
url: {
getAddForm: '/laws/standard/overseas/getFormModel',
getDocumentInfo: '/laws/standard/overseas/getByIdAndModule',
add: '/laws/standard/overseas/commonAdd',
edit: '/laws/standard/overseas/commonEdit'
}
}
},
methods: {
add () {
this.visible = true
this.$nextTick(() => {
this.$refs.addForm.add()
})
},
edit (record) {
this.visible = true
},
handleOk () {
this.confirmLoading = true
this.$refs.addForm.submit()
},
// 表单提交的回调,获取表单数据
submitFormData (formInline) {
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
}
}
}
</script>
<style scoped>
</style>