FormData.js
1.37 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
module.exports = {
/**
* 检测富文本内容
* @param {object} object 富文本对象集
* @param {object} object.editor_temp_data 富文本对象集
* @param {object} object.field_infos 富文本对象说明
* @param {boolean} object.type 是否返回boolean值
* @return {object or boolean} 如果传了type返回Boolean,否则返回验证信息
*/
onCheckEditor({
editor_temp_data,
field_infos,
type
}) {
var obj = {
status: 200
};
for (var id in editor_temp_data) {
if (!editor_temp_data[id].text) {
if ((editor_temp_data[id].html.indexOf('<iframe') == -1 || editor_temp_data[id].html.indexOf('</iframe>') == -1) && (editor_temp_data[id].html.indexOf('<img') == -1)) {
if (field_infos && field_infos[id]) {
this.$message.error(field_infos[id].msg);
}
obj.status = 1;
obj.id = id;
break;
}
}
}
return type === true ? obj.status === 200 : obj;
},
onSubmit({
data,
editor_temp_data
}) {
if (editor_temp_data) {
var check = this.onCheckEditor({
editor_temp_data,
field_infos: this.tips,
type: true
});
if (check) {
for (var f in this.tips) {
data[this.tips[f].field] = editor_temp_data[f].html;
}
this.onSubmitFn && this.onSubmitFn(data);
}
} else {
this.onSubmitFn && this.onSubmitFn(data);
}
}
};