operate.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage', 'citypicker'], function ($, undefined, Backend, Table, Form, SelectPage, Citypicker) {
  2. let Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'institution/institution/index' + location.search,
  8. add_url: '',
  9. edit_url: '',
  10. del_url: '',
  11. multi_url: 'institution/institution/multi',
  12. table: 'institution',
  13. }
  14. });
  15. let table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'createdAt',
  21. showToggle: false,
  22. showColumns: false,
  23. exportOptions: {
  24. ignoreColumn: ['operate'], //默认不导出第一列(checkbox)与操作(operate)列
  25. },
  26. queryParams: function (params) {
  27. //这里可以追加搜索条件
  28. let filter = JSON.parse(params.filter);
  29. let op = JSON.parse(params.op);
  30. if(filter.ris_province){
  31. delete op.ris_province;
  32. let arr = filter.ris_province.split("/");
  33. delete filter.ris_province;
  34. if(arr[0]){
  35. filter['ris_province'] = arr[0];
  36. op['ris_province'] = '=';
  37. }
  38. if(arr[1]){
  39. filter['ris_city'] = arr[1];
  40. op['ris_city'] = '=';
  41. }
  42. }
  43. params.filter = JSON.stringify(filter);
  44. params.op = JSON.stringify(op);
  45. common_filter = params.filter;
  46. common_op = params.op;
  47. return params;
  48. },
  49. columns: [
  50. [
  51. {field: 'name', title: __('Name'), operate: 'LIKE %...%',formatter: Controller.api.formatter.name, align: "left"},
  52. {field: 'id', title: __('Id')},
  53. {
  54. field: 'institution_level',
  55. title: __('Institution_level'),
  56. // operate: 'LIKE %...%',
  57. searchList: $.getJSON('institution/institution/levelSelectList')
  58. },
  59. // {field: 'address', title: __('Address'), searchable: false},
  60. {
  61. field: 'charge_mode',
  62. title: __('收费模式'),
  63. formatter: Table.api.formatter.label,
  64. searchList: {
  65. 1: '患者支付', 2: '医院托管', 3: '医院代收'
  66. },
  67. },
  68. {field: 'ris_province', title: '省市', visible: false},
  69. {
  70. field: 'createdAt',
  71. title: __('Createdat'),
  72. operate: 'RANGE',
  73. addclass: 'datetimerange',
  74. sortable: true
  75. },
  76. {field: 'updatedAt', title: __('Updatedat'), operate: 'RANGE', addclass: 'datetimerange'},
  77. {field: 'install_time', title: '安装时间', searchable: false},
  78. {
  79. field: 'status',
  80. title: __('Status'),
  81. formatter: Table.api.formatter.status,
  82. searchList: {1: '启用', 2: '禁用'},
  83. custom: {1: 'success', 2: 'danger'},
  84. },{
  85. field: 'operate_close',
  86. title: __('关闭操作开关'),
  87. formatter: function (value) {
  88. if(value == '0'){return '默认'}else{return '已禁用所有操作';}
  89. },
  90. searchList: {0: '默认', 2: '已禁用所有操作'},
  91. },
  92. {
  93. field: 'operate',
  94. export:false,
  95. title: __('Operate'),
  96. table: table,
  97. buttons: [
  98. {
  99. name : 'closeAllOperate',
  100. title : __('操作停用'),
  101. extend : 'data-toggle="tooltip"',
  102. classname: 'btn btn-xs btn-primary btn-dialog',
  103. icon : 'fa fa-stop',
  104. url : 'institution/operate/closeAllOperate',
  105. },
  106. ],
  107. events: Table.api.events.operate,
  108. formatter: Table.api.formatter.operate,
  109. }
  110. ]
  111. ]
  112. });
  113. $('#ris_province').attr('data-level','city')
  114. $('#ris_province').citypicker();
  115. $('.city-select').css('white-space','initial');
  116. $('.city-picker-span').css('width','100%');
  117. // 为表格绑定事件
  118. Table.api.bindevent(table);
  119. // initInstitutionSearchList('parent_institution');
  120. },
  121. add: function () {
  122. initAgentSearchList('c-agent_id');
  123. initSaleSearchList('c-sale_id');
  124. // initFilterList('filter');
  125. Controller.api.bindevent();
  126. },
  127. edit: function () {
  128. initAgentSearchList('c-agent_id');
  129. initSaleSearchList('c-sale_id')
  130. Controller.api.bindevent();
  131. },
  132. setchargemode: function () {
  133. Controller.api.bindevent();
  134. },
  135. setmonitoring: function () {
  136. Controller.api.bindevent();
  137. },
  138. topup: function (){
  139. $('#input-money').focus()
  140. Controller.api.bindevent();
  141. },
  142. setdict: function (){
  143. Controller.api.bindevent();
  144. },
  145. closealloperate: function (){
  146. Controller.api.bindevent();
  147. },
  148. api: {
  149. bindevent: function () {
  150. $('#c-name').change(function () {
  151. $('#area-picker').trigger('cp:updated')
  152. })
  153. $('#area-picker').on("cp:updated", function () {
  154. if($(this).val().split('/').length === 3){
  155. let city = $(this).val().replace(/\//g,'')
  156. let name = $('#c-name').val()
  157. if(!name){
  158. return false
  159. }
  160. Fast.api.ajax({
  161. url: 'institution/institution/getLngLat',
  162. data: {
  163. name : city + name
  164. }
  165. }, function (data) {
  166. $('#c-lng').val(data.lng)
  167. $('#c-lat').val(data.lat)
  168. });
  169. }
  170. })
  171. $('#show-map').click(function () {
  172. Fast.api.ajax({
  173. url: 'institution/institution/showMap',
  174. data: {
  175. lng : $('#c-lng').val(),
  176. lat : $('#c-lat').val()
  177. }
  178. }, function (data) {
  179. Fast.api.open(data.url,'地图')
  180. });
  181. })
  182. Form.api.bindevent($("form[role=form]"));
  183. },
  184. formatter: {
  185. name: function (value) {
  186. return "<strong>" + value + "</strong>";
  187. },
  188. is_pay: function (value) {
  189. let str;
  190. switch (value) {
  191. case 0:
  192. str = "不收费";
  193. break;
  194. case 1:
  195. str = "收费&emsp;";
  196. break;
  197. default:
  198. return false;
  199. }
  200. return str;
  201. }
  202. }
  203. }
  204. };
  205. // 选择机构下拉列表
  206. let initInstitutionSearchList = function (id) {
  207. $.ajax({
  208. url: 'institution/institution/institutionSelectList',
  209. type: 'post',
  210. dataType: 'json',
  211. success: function success(res) {
  212. var data = res.rows;
  213. $('#'+id).selectPage({
  214. data : data,
  215. orderBy: 'index',
  216. multiple: true,
  217. });
  218. }
  219. });
  220. };
  221. // 代理商下拉列表
  222. let initAgentSearchList = function (id) {
  223. $.ajax({
  224. url: 'institution/institution/agentSelectList',
  225. type: 'post',
  226. dataType: 'json',
  227. success: function success(res) {
  228. var data = res.rows;
  229. $('#'+id).selectPage({
  230. data : data
  231. });
  232. }
  233. });
  234. };
  235. // 代理商下拉列表
  236. let initSaleSearchList = function (id) {
  237. $.ajax({
  238. url: 'institution/institution/saleSelectList',
  239. type: 'post',
  240. dataType: 'json',
  241. success: function success(res) {
  242. var data = res.rows;
  243. $('#'+id).selectPage({
  244. data : data,
  245. multiple: true,
  246. });
  247. }
  248. });
  249. };
  250. // 过滤条件下拉列表
  251. let initFilterList = function (id) {
  252. $.ajax({
  253. url: 'institution/institution/filterList',
  254. type: 'post',
  255. dataType: 'json',
  256. success: function success(res) {
  257. var data = res.rows;
  258. $('.'+id).selectPage({
  259. data : data,
  260. multiple: false,
  261. });
  262. }
  263. });
  264. };
  265. return Controller;
  266. });