提交 53af950e authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 4bbbfb2b
...@@ -16,7 +16,8 @@ export default { ...@@ -16,7 +16,8 @@ export default {
title: '缴报名费', title: '缴报名费',
visible() { visible() {
return this.tabActive !== 'application_info_first' return this.tabActive !== 'application_info_first'
} },
show: false
} }
] ]
} }
...@@ -12,8 +12,12 @@ export default { ...@@ -12,8 +12,12 @@ export default {
get: { get: {
action: '/api/enrollment/v1.0/application-materials/1005', action: '/api/enrollment/v1.0/application-materials/1005',
callback(data) { callback(data) {
this.form.options.disabled = data.data.material.submission_status === 'SUBMITTED' const {
const { basic_info: basicInfo = {}, attachments = [] } = data.data.material basic_info: basicInfo = {},
attachments = [],
submission_stage: submissionStage = 'FILLING'
} = data.data.material
this.form.options.disabled = submissionStage !== 'FILLING'
const attachment = attachments.reduce( const attachment = attachments.reduce(
(result, item) => { (result, item) => {
const types = ['ID_CARD_FRONT', 'ID_CARD_BACK', 'HK_ID_CARD', 'PASSPORT', 'OTHER_ID_CARD_PHOTO'] const types = ['ID_CARD_FRONT', 'ID_CARD_BACK', 'HK_ID_CARD', 'PASSPORT', 'OTHER_ID_CARD_PHOTO']
...@@ -58,8 +62,8 @@ export default { ...@@ -58,8 +62,8 @@ export default {
} }
}, },
form: { form: {
prev: { to: { query: { active: 'application_info', tab: 'application_info_first' } } }, prev: { to: { query: { active: 'application_info', tab: 'application_info_first' } }, isSubmit: true },
next: { to: { query: { active: 'application_info', tab: 'application_info_education' } } }, next: { to: { query: { active: 'application_info', tab: 'application_info_education' } }, isSubmit: true },
options: { labelWidth: '140px' }, options: { labelWidth: '140px' },
items: [ items: [
{ {
......
...@@ -35,22 +35,32 @@ export default { ...@@ -35,22 +35,32 @@ export default {
prev: { to: { query: { active: 'application_info', tab: 'application_info_honor' } } }, prev: { to: { query: { active: 'application_info', tab: 'application_info_honor' } } },
next: { to: { query: { active: 'application_wfzzm' } } }, next: { to: { query: { active: 'application_wfzzm' } } },
hasAdd: true, hasAdd: true,
minLength: 3,
disabled(data) {
return !!data.letter_content
},
aside: { aside: {
prepend: {
html: '<p style="color:#33C011;">推荐人已完成</p>',
visible(data) { visible(data) {
console.log(data)
return !!data.letter_content return !!data.letter_content
}
}, },
prepend: '<p style="color:#33C011;">推荐人已完成</p>',
buttons: [ buttons: [
{ {
text: '再次邀请', text: '再次邀请',
canShow() {}, visible(data) {
return data.id && !data.letter_content
},
onClick(data) { onClick(data) {
console.log(data, this) console.log(data, this)
} }
}, },
{ {
text: '更换推荐人', text: '更换推荐人',
visible(data) {
return data.id && !data.letter_content
},
onClick(data) { onClick(data) {
console.log(data, this) console.log(data, this)
} }
......
{ {
"name": "@ezijing/vue-form", "name": "@ezijing/vue-form",
"version": "0.2.7", "version": "2.0.3",
"private": false, "private": false,
"description": "基于Vue Element-UI的表单", "description": "基于Vue Element-UI的表单",
"scripts": { "scripts": {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<div class="v-form-group" :key="index"> <div class="v-form-group" :key="index">
<div class="v-form-group__inner"> <div class="v-form-group__inner">
<v-form <v-form
:disabled="form.disabled && form.disabled(item)"
:options="form.options" :options="form.options"
:items="form.items" :items="form.items"
:model="item" :model="item"
...@@ -19,19 +20,30 @@ ...@@ -19,19 +20,30 @@
class="v-form-group__content" class="v-form-group__content"
></v-form> ></v-form>
<template v-if="form.aside"> <template v-if="form.aside">
<div class="v-form-group__aside" v-if="form.aside.visible(item)"> <div class="v-form-group__aside">
<div v-html="form.aside.prepend"></div> <div
v-html="form.aside.prepend.html"
v-if="form.aside.prepend.visible && form.aside.prepend.visible(item)"
></div>
<div> <div>
<div v-for="(button, index) in form.aside.buttons" :key="index"> <div v-for="(button, index) in form.aside.buttons" :key="index">
<el-button type="primary" size="medium" plain @click="button.onClick(item)">{{ <el-button
button.text type="primary"
}}</el-button> size="medium"
plain
@click="button.onClick(item)"
v-if="button.visible && button.visible(item)"
>
{{ button.text }}</el-button
>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
</div> </div>
<template v-if="index > currentForm.minlength - 1">
<div class="v-form-group__remove" @click="handleRemove(index)">删除</div> <div class="v-form-group__remove" @click="handleRemove(index)">删除</div>
</template>
</div> </div>
</template> </template>
<div class="v-form-group__add"> <div class="v-form-group__add">
...@@ -97,7 +109,7 @@ export default { ...@@ -97,7 +109,7 @@ export default {
return Array.isArray(this.model) return Array.isArray(this.model)
}, },
currentForm() { currentForm() {
return Object.assign({ hasSubmit: true, hasButton: true, options: {} }, this.form) return Object.assign({ minlength: 1, hasSubmit: true, hasButton: true, options: {} }, this.form)
}, },
that() { that() {
return this return this
...@@ -168,7 +180,7 @@ export default { ...@@ -168,7 +180,7 @@ export default {
}, },
// 提交 // 提交
async handleSubmit() { async handleSubmit() {
if (this.currentForm.options.disabled) { if (this.currentForm.options.disabled || !this.update) {
return return
} }
const form = this.$refs.form const form = this.$refs.form
...@@ -179,7 +191,10 @@ export default { ...@@ -179,7 +191,10 @@ export default {
}) })
}, },
// 上一步 // 上一步
handlePrev() { async handlePrev() {
if (this.form.prev.isSubmit) {
await this.handleSubmit()
}
this.$emit('prev', this.form.prev.to) this.$emit('prev', this.form.prev.to)
}, },
// 下一步 // 下一步
......
<template> <template>
<div class="v-form"> <div class="v-form">
<div class="v-form__prepend" v-html="options.prepend"></div> <div class="v-form__prepend" v-html="options.prepend"></div>
<el-form v-bind="options" ref="form" :model="ruleForm" @submit.native.prevent v-on="$listeners"> <el-form
:disabled="disabled || options.disabled"
v-bind="options"
ref="form"
:model="ruleForm"
@submit.native.prevent
v-on="$listeners"
>
<template v-for="item in currentItems"> <template v-for="item in currentItems">
<el-form-item v-bind="item" :prop="item.model" :key="item.model"> <el-form-item v-bind="item" :prop="item.model" :key="item.model">
<div class="v-form-item__prepend" v-html="item.prepend"></div> <div class="v-form-item__prepend" v-html="item.prepend"></div>
...@@ -23,6 +30,7 @@ ...@@ -23,6 +30,7 @@
export default { export default {
name: 'VForm', name: 'VForm',
props: { props: {
disabled: { type: Boolean, default: false },
options: { options: {
type: Object, type: Object,
default() { default() {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:class="{ 'v-submenu__item': true, 'is-active': item.isActive }" :class="{ 'v-submenu__item': true, 'is-active': item.isActive }"
:key="item.id" :key="item.id"
@click="$emit('select', item.id, item)" @click="$emit('select', item.id, item)"
v-if="item.show === undefined ? true : item.show"
> >
<span>{{ item.title }}</span> <span>{{ item.title }}</span>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论