123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var tag = 0;
- $(document).on('click','#submit',function () {
- if(tag == 1){
- layer.alert('请不要频繁提交');
- return false;
- }
- tag = 1;
- if($.trim($("#c-desc").val()) == ''){
- tag = 0;
- layer.alert('描述不能为空');
- return false;
- }
- var datas = {
- 'status':$("#status").val(),
- 'section':$("#c-section").val(),
- 'desc':$("#c-desc").val(),
- };
- $.ajax({
- type: "POST",
- dataType: "json",
- url: "/admin/manage/sharedesc/addmany",
- data: datas,
- success: function (result) {
- if(typeof result == "string"){
- result = JSON.parse(result);
- }
- if (result.success == '1') {
- tag = 0;
- $("#c-desc").val('');
- layer.alert('添加成功');
- $('.btn-refresh').click();
- }else{
- tag = 0;
- layer.alert('异常!');
- }
- },
- error : function() {
- tag = 0;
- layer.alert("异常!");
- }
- });
- });
- $(document).on('click', '.btn-pl', function () {
- layer.open({
- type: 2,
- desc: '批量添加描述',
- maxmin: true,
- area: ['60%', '90%'],
- shadeClose: true, //点击遮罩关闭层
- content: '/admin/manage/sharedesc/addmany',
- cancel: function (index,layero) {
- $('.btn-refresh').click();
- layer.close(index);
- },
- });
- });
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'manage/sharedesc/index',
- add_url: 'manage/sharedesc/add',
- edit_url: 'manage/sharedesc/edit',
- del_url: 'manage/sharedesc/del',
- multi_url: 'manage/sharedesc/multi',
- table: 'manage_sharedesc',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'desc', title: __('Desc')},
- {field: 'status', title: __('Status'), visible:false, searchList: {"normal":__('status normal'),"hidden":__('status hidden')}},
- {field: 'status_text', title: __('Status'), operate:false},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {field: 'section', title: __('Section'), visible:false, searchList: {"section 1":__('Section 1'),"section 2":__('Section 2'),"section 3":__('Section 3')}},
- {field: 'section_text', title: __('Section'), operate:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|