123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage', 'citypicker'], function ($, undefined, Backend, Table, Form, SelectPage, Citypicker) {
- let Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'institution/institution/index' + location.search,
- add_url: '',
- edit_url: '',
- del_url: '',
- multi_url: 'institution/institution/multi',
- table: 'institution',
- }
- });
- let table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'createdAt',
- showToggle: false,
- showColumns: false,
- exportOptions: {
- ignoreColumn: ['operate'], //默认不导出第一列(checkbox)与操作(operate)列
- },
- queryParams: function (params) {
- //这里可以追加搜索条件
- let filter = JSON.parse(params.filter);
- let op = JSON.parse(params.op);
- if(filter.ris_province){
- delete op.ris_province;
- let arr = filter.ris_province.split("/");
- delete filter.ris_province;
- if(arr[0]){
- filter['ris_province'] = arr[0];
- op['ris_province'] = '=';
- }
- if(arr[1]){
- filter['ris_city'] = arr[1];
- op['ris_city'] = '=';
- }
- }
- params.filter = JSON.stringify(filter);
- params.op = JSON.stringify(op);
- common_filter = params.filter;
- common_op = params.op;
- return params;
- },
- columns: [
- [
- {field: 'name', title: __('Name'), operate: 'LIKE %...%',formatter: Controller.api.formatter.name, align: "left"},
- {field: 'id', title: __('Id')},
- {
- field: 'institution_level',
- title: __('Institution_level'),
- // operate: 'LIKE %...%',
- searchList: $.getJSON('institution/institution/levelSelectList')
- },
- // {field: 'address', title: __('Address'), searchable: false},
- {
- field: 'charge_mode',
- title: __('收费模式'),
- formatter: Table.api.formatter.label,
- searchList: {
- 1: '患者支付', 2: '医院托管', 3: '医院代收'
- },
- },
- {field: 'ris_province', title: '省市', visible: false},
- {
- field: 'createdAt',
- title: __('Createdat'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- sortable: true
- },
- {field: 'updatedAt', title: __('Updatedat'), operate: 'RANGE', addclass: 'datetimerange'},
- {field: 'install_time', title: '安装时间', searchable: false},
- {
- field: 'status',
- title: __('Status'),
- formatter: Table.api.formatter.status,
- searchList: {1: '启用', 2: '禁用'},
- custom: {1: 'success', 2: 'danger'},
- },{
- field: 'operate_close',
- title: __('关闭操作开关'),
- formatter: function (value) {
- if(value == '0'){return '默认'}else{return '已禁用所有操作';}
- },
- searchList: {0: '默认', 2: '已禁用所有操作'},
- },
- {
- field: 'operate',
- export:false,
- title: __('Operate'),
- table: table,
- buttons: [
- {
- name : 'closeAllOperate',
- title : __('操作停用'),
- extend : 'data-toggle="tooltip"',
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon : 'fa fa-stop',
- url : 'institution/operate/closeAllOperate',
- },
- ],
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate,
- }
- ]
- ]
- });
- $('#ris_province').attr('data-level','city')
- $('#ris_province').citypicker();
- $('.city-select').css('white-space','initial');
- $('.city-picker-span').css('width','100%');
- // 为表格绑定事件
- Table.api.bindevent(table);
- // initInstitutionSearchList('parent_institution');
- },
- add: function () {
- initAgentSearchList('c-agent_id');
- initSaleSearchList('c-sale_id');
- // initFilterList('filter');
- Controller.api.bindevent();
- },
- edit: function () {
- initAgentSearchList('c-agent_id');
- initSaleSearchList('c-sale_id')
- Controller.api.bindevent();
- },
- setchargemode: function () {
- Controller.api.bindevent();
- },
- setmonitoring: function () {
- Controller.api.bindevent();
- },
- topup: function (){
- $('#input-money').focus()
- Controller.api.bindevent();
- },
- setdict: function (){
- Controller.api.bindevent();
- },
- closealloperate: function (){
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- $('#c-name').change(function () {
- $('#area-picker').trigger('cp:updated')
- })
- $('#area-picker').on("cp:updated", function () {
- if($(this).val().split('/').length === 3){
- let city = $(this).val().replace(/\//g,'')
- let name = $('#c-name').val()
- if(!name){
- return false
- }
- Fast.api.ajax({
- url: 'institution/institution/getLngLat',
- data: {
- name : city + name
- }
- }, function (data) {
- $('#c-lng').val(data.lng)
- $('#c-lat').val(data.lat)
- });
- }
- })
- $('#show-map').click(function () {
- Fast.api.ajax({
- url: 'institution/institution/showMap',
- data: {
- lng : $('#c-lng').val(),
- lat : $('#c-lat').val()
- }
- }, function (data) {
- Fast.api.open(data.url,'地图')
- });
- })
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- name: function (value) {
- return "<strong>" + value + "</strong>";
- },
- is_pay: function (value) {
- let str;
- switch (value) {
- case 0:
- str = "不收费";
- break;
- case 1:
- str = "收费 ";
- break;
- default:
- return false;
- }
- return str;
- }
- }
- }
- };
- // 选择机构下拉列表
- let initInstitutionSearchList = function (id) {
- $.ajax({
- url: 'institution/institution/institutionSelectList',
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- var data = res.rows;
- $('#'+id).selectPage({
- data : data,
- orderBy: 'index',
- multiple: true,
- });
- }
- });
- };
- // 代理商下拉列表
- let initAgentSearchList = function (id) {
- $.ajax({
- url: 'institution/institution/agentSelectList',
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- var data = res.rows;
- $('#'+id).selectPage({
- data : data
- });
- }
- });
- };
- // 代理商下拉列表
- let initSaleSearchList = function (id) {
- $.ajax({
- url: 'institution/institution/saleSelectList',
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- var data = res.rows;
- $('#'+id).selectPage({
- data : data,
- multiple: true,
- });
- }
- });
- };
- // 过滤条件下拉列表
- let initFilterList = function (id) {
- $.ajax({
- url: 'institution/institution/filterList',
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- var data = res.rows;
- $('.'+id).selectPage({
- data : data,
- multiple: false,
- });
- }
- });
- };
- return Controller;
- });
|