WhisperingsForm.vue
4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<template>
<a-comment>
<span key='comment-nested-reply-to' slot='actions'>Reply to</span>
<a slot='author'>Han Solo</a>
<a-avatar
slot='avatar'
alt='Han Solo'
src='https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'
/>
<p slot='content'>
We supply a series of design principles, practical patterns and high quality design resources
(Sketch and Axure).
</p>
<a-comment>
<span slot='actions'>Reply to</span>
<a slot='author'>Han Solo</a>
<a-avatar
slot='avatar'
alt='Han Solo'
src='https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'
/>
<p slot='content'>
We supply a series of design principles, practical patterns and high quality design
resources (Sketch and Axure).
</p>
<a-comment>
<span slot='actions'>Reply to</span>
<a slot='author'>Han Solo</a>
<a-avatar
slot='avatar'
alt='Han Solo'
src='https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'
/>
<p slot='content'>
We supply a series of design principles, practical patterns and high quality design
resources (Sketch and Axure).
</p>
</a-comment>
<a-comment>
<span slot='actions'>Reply to</span>
<a slot='author'>Han Solo</a>
<a-avatar
slot='avatar'
alt='Han Solo'
src='https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'
/>
<p slot='content'>
We supply a series of design principles, practical patterns and high quality design
resources (Sketch and Axure).
</p>
</a-comment>
</a-comment>
</a-comment>
</template>
<script>
import { VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin'
import WhisperingsReplyForm from './WhisperingsReplyForm.vue'
export default {
name: 'WhisperingsForm',
mixins: [JEditableTableModelMixin],
components: {
WhisperingsReplyForm
},
data() {
return {
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
labelCol2: {
xs: { span: 24 },
sm: { span: 3 }
},
wrapperCol2: {
xs: { span: 24 },
sm: { span: 20 }
},
model: {},
// 新增时子表默认添加几行空数据
addDefaultRowNum: 1,
validatorRules: {},
refKeys: ['whisperingsReply'],
tableKeys: [],
activeKey: 'whisperingsReply',
// 悄悄话回复
whisperingsReplyTable: {
loading: false,
dataSource: [],
columns: []
},
url: {
add: '/inspect/whisperings/add',
edit: '/inspect/whisperings/edit',
queryById: '/inspect/whisperings/queryById',
whisperingsReply: {
list: '/inspect/whisperings/queryWhisperingsReplyByMainId'
}
}
}
},
props: {
//表单禁用
disabled: {
type: Boolean,
default: false,
required: false
}
},
computed: {
formDisabled() {
return this.disabled
}
},
created() {
},
methods: {
addBefore() {
this.$refs.whisperingsReplyForm.clearFormData()
},
getAllTable() {
return new Promise(resolve => {
resolve([])
})
},
/** 调用完edit()方法之后会自动调用此方法 */
editAfter() {
this.$nextTick(() => {
this.$refs.whisperingsReplyForm.initFormData(this.url.whisperingsReply.list, this.model.id)
})
// 加载子表数据
if (this.model.id) {
let params = { id: this.model.id }
}
},
//校验所有一对一子表表单
validateSubForm(allValues) {
return new Promise((resolve, reject) => {
Promise.all([
this.$refs.whisperingsReplyForm.validate(0)
]).then(() => {
resolve(allValues)
}).catch(e => {
if (e.error === VALIDATE_NO_PASSED) {
// 如果有未通过表单验证的子表,就自动跳转到它所在的tab
this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
} else {
console.error(e)
}
})
})
},
/** 整理成formData */
classifyIntoFormData(allValues) {
let main = Object.assign(this.model, allValues.formValue)
return {
...main, // 展开
whisperingsReplyList: this.$refs.whisperingsReplyForm.getFormData()
}
},
validateError(msg) {
this.$message.error(msg)
}
}
}
</script>
<style scoped>
</style>