institution.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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: 'institution/institution/add',
  9. edit_url: 'institution/institution/edit',
  10. del_url: 'institution/institution/del',
  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. {field: 'agent_name', title: __('Agent_name'), searchable: false},
  61. {
  62. field: 'charge_mode',
  63. title: __('Charge_mode'),
  64. formatter: Table.api.formatter.label,
  65. searchList: {
  66. 1: '患者支付', 2: '医院托管', 3: '医院代收'
  67. },
  68. },
  69. {field: 'ris_province', title: '省市', visible: false},
  70. {
  71. field: 'createdAt',
  72. title: __('Createdat'),
  73. operate: 'RANGE',
  74. addclass: 'datetimerange',
  75. sortable: true
  76. },
  77. {field: 'updatedAt', title: __('Updatedat'), operate: 'RANGE', addclass: 'datetimerange'},
  78. {field: 'install_time', title: '安装时间', searchable: false},
  79. {
  80. field: 'status',
  81. title: __('Status'),
  82. formatter: Table.api.formatter.status,
  83. searchList: {1: '启用', 2: '禁用'},
  84. custom: {1: 'success', 2: 'danger'},
  85. },
  86. {
  87. field: 'operate',
  88. export:false,
  89. title: __('Operate'),
  90. table: table,
  91. buttons: [
  92. {
  93. name : 'setChargeMode',
  94. title : __('Charge_mode'),
  95. extend : 'data-toggle="tooltip"',
  96. classname: 'btn btn-xs btn-primary btn-dialog',
  97. icon : 'fa fa-cogs',
  98. url : 'institution/institution/setChargeMode',
  99. },
  100. {
  101. name : 'btn_topup',
  102. title : '充值',
  103. extend : 'data-toggle="tooltip"',
  104. classname: 'btn btn-xs btn-info btn-dialog',
  105. icon : 'glyphicon glyphicon-yen',
  106. url : 'institution/institution/topUp',
  107. },
  108. {
  109. name : 'btn_monitoring',
  110. title : '影像监控',
  111. extend : 'data-toggle="tooltip"',
  112. classname: 'btn btn-xs btn-warning btn-dialog',
  113. icon : 'fa fa-exclamation-triangle',
  114. url : 'institution/institution/setMonitoring',
  115. },
  116. ],
  117. events: Table.api.events.operate,
  118. formatter: Table.api.formatter.operate,
  119. }
  120. ]
  121. ]
  122. });
  123. $('#ris_province').attr('data-level','city')
  124. $('#ris_province').citypicker();
  125. $('.city-select').css('white-space','initial');
  126. $('.city-picker-span').css('width','100%');
  127. // 为表格绑定事件
  128. Table.api.bindevent(table);
  129. // initInstitutionSearchList('parent_institution');
  130. },
  131. add: function () {
  132. initAgentSearchList('c-agent_id');
  133. initSaleSearchList('c-sale_id');
  134. // initFilterList('filter');
  135. Controller.api.bindevent();
  136. },
  137. edit: function () {
  138. initAgentSearchList('c-agent_id');
  139. initSaleSearchList('c-sale_id')
  140. Controller.api.bindevent();
  141. },
  142. setchargemode: function () {
  143. Controller.api.bindevent();
  144. },
  145. setmonitoring: function () {
  146. Controller.api.bindevent();
  147. },
  148. topup: function (){
  149. $('#input-money').focus()
  150. Controller.api.bindevent();
  151. },
  152. setdict: function (){
  153. Controller.api.bindevent();
  154. },
  155. closealloperate: function (){
  156. Controller.api.bindevent();
  157. },
  158. api: {
  159. bindevent: function () {
  160. $('#c-name').change(function () {
  161. $('#area-picker').trigger('cp:updated')
  162. })
  163. $('#area-picker').on("cp:updated", function () {
  164. if($(this).val().split('/').length === 3){
  165. let city = $(this).val().replace(/\//g,'')
  166. let name = $('#c-name').val()
  167. if(!name){
  168. return false
  169. }
  170. Fast.api.ajax({
  171. url: 'institution/institution/getLngLat',
  172. data: {
  173. name : city + name
  174. }
  175. }, function (data) {
  176. $('#c-lng').val(data.lng)
  177. $('#c-lat').val(data.lat)
  178. });
  179. }
  180. })
  181. $('#show-map').click(function () {
  182. Fast.api.ajax({
  183. url: 'institution/institution/showMap',
  184. data: {
  185. lng : $('#c-lng').val(),
  186. lat : $('#c-lat').val()
  187. }
  188. }, function (data) {
  189. Fast.api.open(data.url,'地图')
  190. });
  191. })
  192. Form.api.bindevent($("form[role=form]"));
  193. },
  194. formatter: {
  195. name: function (value) {
  196. return "<strong>" + value + "</strong>";
  197. },
  198. is_pay: function (value) {
  199. let str;
  200. switch (value) {
  201. case 0:
  202. str = "不收费";
  203. break;
  204. case 1:
  205. str = "收费&emsp;";
  206. break;
  207. default:
  208. return false;
  209. }
  210. return str;
  211. }
  212. }
  213. }
  214. };
  215. // 选择机构下拉列表
  216. let initInstitutionSearchList = function (id) {
  217. $.ajax({
  218. url: 'institution/institution/institutionSelectList',
  219. type: 'post',
  220. dataType: 'json',
  221. success: function success(res) {
  222. var data = res.rows;
  223. $('#'+id).selectPage({
  224. data : data,
  225. orderBy: 'index',
  226. multiple: true,
  227. });
  228. }
  229. });
  230. };
  231. // 代理商下拉列表
  232. let initAgentSearchList = function (id) {
  233. $.ajax({
  234. url: 'institution/institution/agentSelectList',
  235. type: 'post',
  236. dataType: 'json',
  237. success: function success(res) {
  238. var data = res.rows;
  239. $('#'+id).selectPage({
  240. data : data
  241. });
  242. }
  243. });
  244. };
  245. // 代理商下拉列表
  246. let initSaleSearchList = function (id) {
  247. $.ajax({
  248. url: 'institution/institution/saleSelectList',
  249. type: 'post',
  250. dataType: 'json',
  251. success: function success(res) {
  252. var data = res.rows;
  253. $('#'+id).selectPage({
  254. data : data,
  255. multiple: true,
  256. });
  257. }
  258. });
  259. };
  260. // 过滤条件下拉列表
  261. let initFilterList = function (id) {
  262. $.ajax({
  263. url: 'institution/institution/filterList',
  264. type: 'post',
  265. dataType: 'json',
  266. success: function success(res) {
  267. var data = res.rows;
  268. $('.'+id).selectPage({
  269. data : data,
  270. multiple: false,
  271. });
  272. }
  273. });
  274. };
  275. return Controller;
  276. });