123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'agreement/index',
- add_url: 'agreement/add',
- edit_url: 'agreement/edit',
- del_url: 'agreement/del',
- multi_url: 'agreement/multi',
- import_url: 'agreement/import',
- down_url: 'agreement/downpdf',
- multidownpdf_url: 'agreement/multidownpdf',
- table: 'agreement',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- commonSearch: true,
- searchFormVisible: true,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'admin_id', title: __('Admin_id'), operate: false, visible: false},
- {field: 'username_a', title: __('Username_a'), operate: false},
- {field: 'username_b', title: __('Username_b'), operate:"LIKE %...%"},
- {field: 'cardid_b', title: __('Cardid_b'), operate: false, visible: false},
- {field: 'mobile_b', title: __('Mobile_b'), operate: false, visible: false},
- //{field: 'sign_status', title: __('Sign_status'), visible:false, searchList: {"sign_status 1":__('Sign_status 1'),"sign_status 2":__('Sign_status 2')}},
- {field: 'sign_status_text', title: __('Sign_status'), operate:false},
- {
- field: 'template_type',
- title: __('template_type'),
- operate: false,
- formatter: function (value, row, index) {
- if (value == '2') {
- return '模板二';
- } else if (value == '1') {
- return '模板一';
- }
- }
- },
- /* {field: 'status', title: __('Status'), visible:false, searchList: {"normal":__('status normal'),"hidden":__('status hidden')}},
- {field: 'status_text', title: __('Status'), operate:false, visible: false},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible: false},
- {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible: false},*/
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Controller.api.events.operate,
- buttons: [
- {
- name: 'operate',
- text: __('查看'),
- title: __('查看'),
- classname: 'btn btn-xs btn-success btn-editone',
- icon: 'fa fa-eye',
- },
- {
- name: 'operate',
- text: __('删除'),
- title: __('删除'),
- classname: 'btn btn-xs btn-danger btn-delone',
- icon: 'fa fa-trash',
- },
- {
- name: 'operate',
- text: __('下载合同'),
- title: __('下载合同'),
- classname: 'btn btn-xs btn-success btn-downone',
- icon: 'fa fa-eye',
- }
- ],
- formatter: Table.api.formatter.buttons
- },
- ]
- ]
- });
- $(".btn-mpdfdown").click(function(){
- var options = table.bootstrapTable('getOptions');
- var url = options.extend.down_url;
- var data= table.bootstrapTable('getSelections');
- var ids= '';
- if(data.length > 0 ){
- $.each(data, function (i, item) {
- //ids += item.id + ',';
- url = url+'/ids/'+item.id;
- var aLink = document.createElement('a');
- aLink.download = "cps";
- aLink.href = url;
- document.body.appendChild(aLink);
- aLink.click();
- document.body.removeChild(aLink);
- url = options.extend.down_url;
- });
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- events: {
- operate: {
- 'click .btn-editone': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var table = $(this).closest('table');
- var options = table.bootstrapTable('getOptions');
- var ids = row[options.pk];
- row = $.extend({}, row ? row : {}, {ids: ids});
- var url = options.extend.edit_url;
- Fast.api.open(Table.api.replaceurl(url, row, table), '查看', $(this).data() || {});
- },
- 'click .btn-delone': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var that = this;
- var top = $(that).offset().top - $(window).scrollTop();
- var left = $(that).offset().left - $(window).scrollLeft() - 260;
- if (top + 154 > $(window).height()) {
- top = top - 154;
- }
- if ($(window).width() < 480) {
- top = left = undefined;
- }
- Layer.confirm(
- __('Are you sure you want to delete this item?'),
- {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true},
- function (index) {
- var table = $(that).closest('table');
- var options = table.bootstrapTable('getOptions');
- Table.api.multi("del", row[options.pk], table, that);
- Layer.close(index);
- }
- );
- },
- 'click .btn-downone': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var table = $(this).closest('table');
- var options = table.bootstrapTable('getOptions');
- var ids = row[options.pk];
- row = $.extend({}, row ? row : {}, {ids: ids});
- var url = options.extend.down_url;
- url = Table.api.replaceurl(url, row, table);
- $(location).prop('href', url);
- },
- }
- },
- }
- };
- return Controller;
- });
|