templetEdit.js
1.36 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
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
require('../../../common/umeditor.config');
require('../../../common/umeditor');
require('../../../common/zh-cn');
var edit = require('../../../common/edit');
var UMdescriptioner = UM.getEditor('templet');
UMdescriptioner.setContent($("#searchTemplet").val());
var mainData = window.ViewModel;
console.log(mainData);
var e = new edit("#basicForm", {bucket: "goodsimg"});
e.on("validate", function () {
if ($.trim($('#caption').val()) === ''){
return "名称不能为空";
}
if ($.trim(UMdescriptioner.getContent()) === ''){
return "内容不能为空";
}
return true;
});
e.init();
$(document).on('click','#save_templet',function () {
e.submit($("#basicForm").attr("action"), function (option) {
option.data.templet = UMdescriptioner.getContent();
option.success = function (res) {
if (res.code == "200") {
e.$tip("提交成功", function () {
location.href = "/search/templetIndex"
}, 'growl-success');
} else {
e.$tip(res.message);
}
return false;
};
option.error = function (res) {
e.$tip(res.message);
};
console.log(option.data);
});
return false;
});