VUE动态生成动态生成word的实现的实现
主要介绍了VUE动态生成word的实现,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
不废话,直接上代码。
前端代码:
<template>
<Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="110">
<FormItem label="项目(全称):" prop="orgName">
<Input v-model="formValidate.orgName" placeholder="请输入项目名称"></Input>
</FormItem>
<FormItem label="申请人:" prop="applyName" >
<Input v-model="formValidate.applyName" placeholder="请输入申请人"></Input>
</FormItem>
<FormItem label="电话:" prop="applyPhone">
<Input v-model="formValidate.applyPhone" placeholder="请输入电话"></Input>
</FormItem>
<FormItem label="生效日期:" style="float: left">
<Row>
<FormItem prop="startDate">
<DatePicker type="date" format="yyyy-MM-dd" placeholder="请选择生效日期" v-model="formValidate.startData"></DatePicker>
</FormItem>
</Row>
</FormItem>
<FormItem label="失效日期:">
<Row>
<FormItem prop="endDate">
<DatePicker type="date" format="yyyy-MM-dd" placeholder="请选择失效日期" v-model="formValidate.endData"></DatePicker>
</FormItem>
</Row>
</FormItem>
<FormItem label="备注:" prop="vmemo">
<Input v-model="formValidate.vmemo" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="备注"></Input>
</FormItem>
<FormItem>
<Button type="primary" @click="handleSubmit('formValidate')">生成申请单</Button>
</FormItem>
</Form>
</template>
<script>
import axios from 'axios';
export default {
data () {
return {
formValidate: {
orgName: '',
applyName: '',
applyPhone: '',
startDate: '',
endDate: '',
vmemo:''
},
ruleValidate: {
orgName: [
{ required: true, message: '项目名称不能为空!', trigger: 'blur' }
],
applyName: [
{ required: true, message: '申请人不能为空!', trigger: 'blur' }
],
applyPhone: [
{ required: true, message: '电话不能为空!', trigger: 'change' }
],
startDate: [
{ required: true, type: 'date', message: '请输入license有效期!', trigger: 'change' }
],
endDate: [
{ required: true, type: 'date', message: '请输入license有效期!', trigger: 'change' }
],
}
}
},
methods: {
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
axios({
method: 'post',
url: this.$store.getters.requestNoteUrl,
data: this.formValidate,
responseType: 'blob'
}).then(res => {
this.download(res.data);
});
}
});
},