daily.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init();
  6. //绑定事件
  7. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  8. var panel = $($(this).attr("href"));
  9. if (panel.length > 0) {
  10. Controller.table[panel.attr("id")].call(this);
  11. $(this).on('click', function (e) {
  12. $($(this).attr("href")).find(".btn-refresh").trigger("click");
  13. });
  14. }
  15. //移除绑定的事件
  16. $(this).unbind('shown.bs.tab');
  17. });
  18. //必须默认触发shown.bs.tab事件
  19. $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
  20. },
  21. table: {
  22. first: function () {
  23. // 初始化表格参数配置
  24. Table.api.init({
  25. extend: {
  26. add_url: 'qingdongams/report/daily/add',
  27. table: 'daily'
  28. }
  29. });
  30. var table = $("#table");
  31. // 初始化表格
  32. table.bootstrapTable({
  33. url: 'qingdongams/report/daily/index?type=0',
  34. toolbar: '#toolbar',
  35. sortName: 'id',
  36. columns: [
  37. [
  38. {field: 'state', checkbox: true},
  39. {field: 'type', title: __('类型'),formatter:Table.api.formatter.status,
  40. searchList: {'日报':'日报', '周报':'周报','月报':'月报','季报':'季报','年报':'年报',}},
  41. {field: 'staff.name', title: __('创建人'),operate:false},
  42. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  43. {
  44. field : 'operate',
  45. title : __('Operate'),
  46. table : table,
  47. events : Table.api.events.operate,
  48. formatter : Table.api.formatter.operate,
  49. buttons : [
  50. {
  51. name: 'detail',
  52. text: __('详情'),
  53. classname: 'records btn-dialog',
  54. url: 'qingdongams/report/daily/detail',
  55. extend: "data-area='[\"80%\", \"80%\"]'",
  56. callback: function (data) {
  57. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  58. }
  59. },
  60. {
  61. name : '评论',
  62. text : __('评论'),
  63. classname : 'records btn-dialog',
  64. url : 'qingdongams/report/daily/comment',
  65. callback: function (data) {
  66. },
  67. }
  68. ]
  69. }
  70. ]
  71. ],
  72. //启用普通表单搜索
  73. commonSearch: true,
  74. searchFormVisible: true,
  75. });
  76. // 为表格绑定事件
  77. Table.api.bindevent(table);
  78. $('.search').hide();
  79. $('.btn-import').hide();
  80. },
  81. second: function () {
  82. // 初始化表格参数配置
  83. Table.api.init({
  84. extend: {
  85. add_url: 'qingdongams/report/daily/add',
  86. table: 'daily'
  87. }
  88. });
  89. var table = $("#table1");
  90. // 初始化表格
  91. table.bootstrapTable({
  92. url: 'qingdongams/report/daily/index?type=1',
  93. toolbar: '#toolbar1',
  94. sortName: 'id',
  95. columns: [
  96. [
  97. {field: 'state', checkbox: true},
  98. {field: 'type', title: __('类型'),formatter:Table.api.formatter.status,
  99. searchList: {'日报':'日报', '周报':'周报','月报':'月报','季报':'季报','年报':'年报',}},
  100. {field: 'staff.name', title: __('创建人'),operate:false},
  101. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  102. {
  103. field : 'operate',
  104. title : __('Operate'),
  105. table : table,
  106. events : Table.api.events.operate,
  107. formatter : Table.api.formatter.operate,
  108. buttons : [
  109. {
  110. name: 'detail',
  111. text: __('详情'),
  112. classname: 'records btn-dialog',
  113. url: 'qingdongams/report/daily/detail',
  114. extend: "data-area='[\"80%\", \"80%\"]'",
  115. callback: function (data) {
  116. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  117. }
  118. },
  119. {
  120. name : '评论',
  121. text : __('评论'),
  122. classname : 'records btn-dialog',
  123. url : 'qingdongams/report/daily/comment',
  124. callback: function (data) {
  125. },
  126. }
  127. ]
  128. }
  129. ]
  130. ],
  131. //启用普通表单搜索
  132. commonSearch: true,
  133. searchFormVisible: true,
  134. });
  135. // 为表格绑定事件
  136. Table.api.bindevent(table);
  137. $('.search').hide();
  138. $('.btn-import').hide();
  139. },
  140. third: function () {
  141. // 初始化表格参数配置
  142. Table.api.init({
  143. extend: {
  144. add_url: 'qingdongams/report/daily/add',
  145. table: 'daily'
  146. }
  147. });
  148. var table = $("#table2");
  149. // 初始化表格
  150. table.bootstrapTable({
  151. url: 'qingdongams/report/daily/index?type=2',
  152. toolbar: '#toolbar2',
  153. sortName: 'id',
  154. columns: [
  155. [
  156. {field: 'state', checkbox: true},
  157. {field: 'type', title: __('类型'),formatter:Table.api.formatter.status,
  158. searchList: {'日报':'日报', '周报':'周报','月报':'月报','季报':'季报','年报':'年报',}},
  159. {field: 'staff.name', title: __('创建人'),operate:false},
  160. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  161. {
  162. field : 'operate',
  163. title : __('Operate'),
  164. table : table,
  165. events : Table.api.events.operate,
  166. formatter : Table.api.formatter.operate,
  167. buttons : [
  168. {
  169. name: 'detail',
  170. text: __('详情'),
  171. classname: 'records btn-dialog',
  172. url: 'qingdongams/report/daily/detail',
  173. extend: "data-area='[\"80%\", \"80%\"]'",
  174. callback: function (data) {
  175. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  176. }
  177. },
  178. {
  179. name : '评论',
  180. text : __('评论'),
  181. classname : 'records btn-dialog',
  182. url : 'qingdongams/report/daily/comment',
  183. callback: function (data) {
  184. },
  185. }
  186. ]
  187. }
  188. ]
  189. ],
  190. //启用普通表单搜索
  191. commonSearch: true,
  192. searchFormVisible: true,
  193. });
  194. // 为表格绑定事件
  195. Table.api.bindevent(table);
  196. $('.search').hide();
  197. $('.btn-import').hide();
  198. },
  199. },
  200. add: function () {
  201. Controller.api.bindevent();
  202. },
  203. comment: function () {
  204. Controller.api.bindevent();
  205. },
  206. edit: function () {
  207. Controller.api.bindevent();
  208. },
  209. detail: function () {
  210. Table.api.init({});
  211. //跟进记录
  212. var table6 = $("#comment");
  213. // 初始化表格
  214. table6.bootstrapTable({
  215. url : 'qingdongams/report/daily/comment_list?relation_id='+Config.idinfo.id,
  216. pk : 'id',
  217. sortName : 'id',
  218. operate : false,
  219. commonSearch : false,
  220. search : false,
  221. visible : false,
  222. showColumns : false,
  223. showExport : false,
  224. showToggle : false,
  225. columns : [
  226. [
  227. {field: 'staff.name', title: __('评论人')},
  228. {field: 'content', title: __('评论内容'),cellStyle:function (value,row,index,field) {
  229. return {
  230. css: {
  231. "min-width": "150px",
  232. "white-space": "nowrap",
  233. "text-overflow": "ellipsis",
  234. "overflow": "hidden",
  235. "max-width":"300px",
  236. 'cursor':"pointer"
  237. }
  238. };
  239. },formatter:function (value,row,index,field) {
  240. var span=document.createElement('span');
  241. span.setAttribute('title',value);
  242. span.innerHTML = value;
  243. return span.outerHTML;
  244. }
  245. },
  246. {field: 'createtime', title: __('评论时间')},
  247. ]
  248. ]
  249. });
  250. Controller.api.bindevent();
  251. },
  252. api: {
  253. bindevent: function () {
  254. require(['backend/qingdongams/common/common'])
  255. Form.api.bindevent($("form[role=form]"));
  256. },
  257. formatter: {
  258. }
  259. }
  260. };
  261. return Controller;
  262. });