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
| el: '#rrapp',
data: {
showList: true,
title: null,
bsaNews: {},
newsTypes: {}
},
created(){
this.getNewsType()
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.bsaNews = {"type":0};
initFileInput("input-b1", baseURL + 'upload/fdsimg', null);
ue.setContent("")
$(".fileinput-remove-button").click();
},
update: function (event) {
var id = getSelectedRow();
if (id == null) {
return;
}
vm.showList = false;
vm.title = "修改";
vm.getInfo(id)
},
saveOrUpdate: function (event) {
$('#btnSaveOrUpdate').button('loading').delay(1000).queue(function () {
var url = vm.bsaNews.id == null ? "sys/bsanews/save" : "sys/bsanews/update";
vm.bsaNews.detail = ue.getContent();
ue.setContent("")
$.ajax({
type: "POST",
url: baseURL + url,
contentType: "application/json",
data: JSON.stringify(vm.bsaNews),
success: function (r) {
if (r.code === 0) {
layer.msg("操作成功", {icon: 1});
vm.reload();
$('#btnSaveOrUpdate').button('reset');
$('#btnSaveOrUpdate').dequeue();
} else {
layer.alert(r.msg);
$('#btnSaveOrUpdate').button('reset');
$('#btnSaveOrUpdate').dequeue();
}
}
});
});
},
del: function (event) {
var ids = getSelectedRows();
if (ids == null) {
return;
}
var lock = false;
layer.confirm('确定要删除选中的记录?', {
btn: ['确定', '取消'] //按钮
}, function () {
if (!lock) {
lock = true;
$.ajax({
type: "POST",
url: baseURL + "sys/bsanews/delete",
contentType: "application/json",
data: JSON.stringify(ids),
success: function (r) {
if (r.code == 0) {
layer.msg("操作成功", {icon: 1});
$("#jqGrid").trigger("reloadGrid");
} else {
layer.alert(r.msg);
}
}
});
}
}, function () {
});
},
getInfo: function (id) {
$.get(baseURL + "sys/bsanews/info/" + id, function (r) {
vm.bsaNews = r.bsaNews;
initFileInput("input-b1", baseURL + 'upload/fdsimg', vm.bsaNews.imgUrl);
ue.setContent(vm.bsaNews.detail)
});
},
reload: function (event) {
vm.showList = true;
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
page: 1
}).trigger("reloadGrid");
},
getNewsType: function (event) {
$.ajax({
type: "POST",
url: baseURL+"bsa/dict/getListByType",
contentType: "application/json",
data: JSON.stringify({"type":"news_type"}),
success: function(result){
if(result.code == 0){//登录成功
vm.newsTypes=result.content
}else{
alert(result.msg)
}
}
});
}
} |