123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init();
- //绑定事件
- $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
- var panel = $($(this).attr("href"));
- if (panel.length > 0) {
- Controller.table[panel.attr("id")].call(this);
- $(this).on('click', function (e) {
- $($(this).attr("href")).find(".btn-refresh").trigger("click");
- });
- }
- //移除绑定的事件
- $(this).unbind('shown.bs.tab');
- });
- //必须默认触发shown.bs.tab事件
- $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
- },
- table: {
- first: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- add_url: 'qingdongams/report/daily/add',
- table: 'daily'
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: 'qingdongams/report/daily/index?type=0',
- toolbar: '#toolbar',
- sortName: 'id',
- columns: [
- [
- {field: 'state', checkbox: true},
- {field: 'type', title: __('类型'),formatter:Table.api.formatter.status,
- searchList: {'日报':'日报', '周报':'周报','月报':'月报','季报':'季报','年报':'年报',}},
- {field: 'staff.name', title: __('创建人'),operate:false},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {
- field : 'operate',
- title : __('Operate'),
- table : table,
- events : Table.api.events.operate,
- formatter : Table.api.formatter.operate,
- buttons : [
- {
- name: 'detail',
- text: __('详情'),
- classname: 'records btn-dialog',
- url: 'qingdongams/report/daily/detail',
- extend: "data-area='[\"80%\", \"80%\"]'",
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- }
- },
- {
- name : '评论',
- text : __('评论'),
- classname : 'records btn-dialog',
- url : 'qingdongams/report/daily/comment',
- callback: function (data) {
- },
- }
- ]
- }
- ]
- ],
- //启用普通表单搜索
- commonSearch: true,
- searchFormVisible: true,
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $('.search').hide();
- $('.btn-import').hide();
- },
- second: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- add_url: 'qingdongams/report/daily/add',
- table: 'daily'
- }
- });
- var table = $("#table1");
- // 初始化表格
- table.bootstrapTable({
- url: 'qingdongams/report/daily/index?type=1',
- toolbar: '#toolbar1',
- sortName: 'id',
- columns: [
- [
- {field: 'state', checkbox: true},
- {field: 'type', title: __('类型'),formatter:Table.api.formatter.status,
- searchList: {'日报':'日报', '周报':'周报','月报':'月报','季报':'季报','年报':'年报',}},
- {field: 'staff.name', title: __('创建人'),operate:false},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {
- field : 'operate',
- title : __('Operate'),
- table : table,
- events : Table.api.events.operate,
- formatter : Table.api.formatter.operate,
- buttons : [
- {
- name: 'detail',
- text: __('详情'),
- classname: 'records btn-dialog',
- url: 'qingdongams/report/daily/detail',
- extend: "data-area='[\"80%\", \"80%\"]'",
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- }
- },
- {
- name : '评论',
- text : __('评论'),
- classname : 'records btn-dialog',
- url : 'qingdongams/report/daily/comment',
- callback: function (data) {
- },
- }
- ]
- }
- ]
- ],
- //启用普通表单搜索
- commonSearch: true,
- searchFormVisible: true,
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $('.search').hide();
- $('.btn-import').hide();
- },
- third: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- add_url: 'qingdongams/report/daily/add',
- table: 'daily'
- }
- });
- var table = $("#table2");
- // 初始化表格
- table.bootstrapTable({
- url: 'qingdongams/report/daily/index?type=2',
- toolbar: '#toolbar2',
- sortName: 'id',
- columns: [
- [
- {field: 'state', checkbox: true},
- {field: 'type', title: __('类型'),formatter:Table.api.formatter.status,
- searchList: {'日报':'日报', '周报':'周报','月报':'月报','季报':'季报','年报':'年报',}},
- {field: 'staff.name', title: __('创建人'),operate:false},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {
- field : 'operate',
- title : __('Operate'),
- table : table,
- events : Table.api.events.operate,
- formatter : Table.api.formatter.operate,
- buttons : [
- {
- name: 'detail',
- text: __('详情'),
- classname: 'records btn-dialog',
- url: 'qingdongams/report/daily/detail',
- extend: "data-area='[\"80%\", \"80%\"]'",
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- }
- },
- {
- name : '评论',
- text : __('评论'),
- classname : 'records btn-dialog',
- url : 'qingdongams/report/daily/comment',
- callback: function (data) {
- },
- }
- ]
- }
- ]
- ],
- //启用普通表单搜索
- commonSearch: true,
- searchFormVisible: true,
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $('.search').hide();
- $('.btn-import').hide();
- },
- },
- add: function () {
- Controller.api.bindevent();
- },
- comment: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- detail: function () {
- Table.api.init({});
- //跟进记录
- var table6 = $("#comment");
- // 初始化表格
- table6.bootstrapTable({
- url : 'qingdongams/report/daily/comment_list?relation_id='+Config.idinfo.id,
- pk : 'id',
- sortName : 'id',
- operate : false,
- commonSearch : false,
- search : false,
- visible : false,
- showColumns : false,
- showExport : false,
- showToggle : false,
- columns : [
- [
- {field: 'staff.name', title: __('评论人')},
- {field: 'content', title: __('评论内容'),cellStyle:function (value,row,index,field) {
- return {
- css: {
- "min-width": "150px",
- "white-space": "nowrap",
- "text-overflow": "ellipsis",
- "overflow": "hidden",
- "max-width":"300px",
- 'cursor':"pointer"
- }
- };
- },formatter:function (value,row,index,field) {
- var span=document.createElement('span');
- span.setAttribute('title',value);
- span.innerHTML = value;
- return span.outerHTML;
- }
- },
- {field: 'createtime', title: __('评论时间')},
- ]
- ]
- });
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- require(['backend/qingdongams/common/common'])
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- }
- }
- };
- return Controller;
- });
|