123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- $(function () {
- $("#jqGrid").Grid({
- url: '../topiccategory/list',
- rownumWidth:60,
- colModel: [
- {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
- {label: '活动类别主题', name: 'title', index: 'title', width: 80},
- {
- label: '活动类别图片链接', name: 'picUrl', index: 'pic_url', width: 80, formatter: function (value) {
- return transImg(value);
- }
- }]
- });
- });
- var vm = new Vue({
- el: '#rrapp',
- data: {
- showList: true,
- title: null,
- topicCategory: {picUrl: ''},
- ruleValidate: {
- title: [
- {required: true, message: '活动类别主题不能为空', trigger: 'blur'}
- ],
- picUrl: [
- {required: true, message: '活动类别图片不能为空', trigger: 'blur'}
- ]
- },
- q: {
- title: ''
- }
- },
- methods: {
- query: function () {
- vm.reload();
- },
- add: function () {
- vm.showList = false;
- vm.title = "新增";
- vm.topicCategory = {picUrl: ''};
- },
- update: function (event) {
- var id = getSelectedRow("#jqGrid");
- if (id == null) {
- return;
- }
- vm.showList = false;
- vm.title = "修改";
- vm.getInfo(id)
- },
- saveOrUpdate: function (event) {
- var url = vm.topicCategory.id == null ? "../topiccategory/save" : "../topiccategory/update";
- Ajax.request({
- type: "POST",
- url: url,
- contentType: "application/json",
- params: JSON.stringify(vm.topicCategory),
- successCallback: function (r) {
- alert('操作成功', function (index) {
- vm.reload();
- });
- }
- });
- },
- del: function (event) {
- var ids = getSelectedRows("#jqGrid");
- if (ids == null) {
- return;
- }
- confirm('确定要删除选中的记录?', function () {
- Ajax.request({
- type: "POST",
- url: "../topiccategory/delete",
- contentType: "application/json",
- params: JSON.stringify(ids),
- successCallback: function (r) {
- alert('操作成功', function (index) {
- vm.reload();
- });
- }
- });
- });
- },
- getInfo: function (id) {
- Ajax.request({
- url: "../topiccategory/info/" + id,
- async: true,
- successCallback: function (r) {
- vm.topicCategory = r.topicCategory;
- }
- });
- },
- reload: function (event) {
- vm.showList = true;
- var page = $("#jqGrid").jqGrid('getGridParam', 'page');
- $("#jqGrid").jqGrid('setGridParam', {
- postData: {'title': vm.q.title},
- page: page
- }).trigger("reloadGrid");
- vm.handleReset('formValidate');
- },
- handleSuccess: function (res, file) {
- vm.topicCategory.picUrl = file.response.url;
- },
- handleFormatError: function (file) {
- this.$Notice.warning({
- title: '文件格式不正确',
- desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
- });
- },
- handleMaxSize: function (file) {
- this.$Notice.warning({
- title: '超出文件大小限制',
- desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
- });
- },
- eyeImage: function () {
- var url = vm.topicCategory.picUrl;
- eyeImage(url);
- },
- handleSubmit: function (name) {
- handleSubmitValidate(this, name, function () {
- vm.saveOrUpdate()
- });
- },
- handleReset: function (name) {
- handleResetForm(this, name);
- }
- }
- });
|