add 列表
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:title="title"
|
||||
:visible="visible"
|
||||
:confirm-loading="confirmLoading"
|
||||
ok-text="确定"
|
||||
cancel-text="取消"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }">
|
||||
<a-form-item label="文档名称">
|
||||
<a-input v-decorator="['model', validatorRules.model]" :maxLength="50" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addFile } from '../../api/fileApi.js'
|
||||
|
||||
export default {
|
||||
name: 'AddFileModal',
|
||||
data () {
|
||||
return {
|
||||
title: '新增',
|
||||
visible: false,
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
validatorRules: {
|
||||
model: {
|
||||
rules: [{ required: true, message: '请输入文档名称' }],
|
||||
validateTrigger: 'blur'
|
||||
}
|
||||
},
|
||||
model: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add () {
|
||||
this.visible = true
|
||||
},
|
||||
handleOk () {
|
||||
this.form.validateFields((errors, values) => {
|
||||
if (!errors) {
|
||||
const formData = Object.assign(this.model, values)
|
||||
this.confirmLoading = true
|
||||
addFile(formData).then(res => {
|
||||
if (res.success) {
|
||||
const data = res.result || {}
|
||||
this.$message.success(res.message)
|
||||
this.$emit('ok')
|
||||
this.close()
|
||||
this.$router.push({
|
||||
path: '/editor',
|
||||
query: {
|
||||
filePath: data.editFilePath,
|
||||
fileName: data.fileName,
|
||||
fileType: 'docx',
|
||||
key: data.id
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.warn(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
close () {
|
||||
this.visible = false
|
||||
this.form.resetFields()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user