123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'mobile_flow/index' + location.search,
- add_url: 'mobile_flow/add',
- edit_url: 'mobile_flow/edit',
- del_url: 'mobile_flow/del',
- multi_url: 'mobile_flow/multi',
- import_url: 'mobile_flow/import',
- batch: 'mobile_flow/batch',
- table: 'mobile',
- cancel_discount: 'mobile_flow/cancelsetdiscount',
- set_discount: 'mobile_flow/setdiscount',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- search:false,
- searchFormVisible:true,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'no', title: __('手机号'),operate: "LIKE"},
- {field: 'province', title: __('省份')},
- {field: 'city', title: __('归属地')},
- {field: 'name', title: __('卡名称')},
- {field: 'network', title: __('运营商'),formatter: Table.api.formatter.label},
- {field: 'proxy.nickname', title: __('代理商'),formatter: Table.api.formatter.label},
- {field: 'brand', title: __('卡品牌'),formatter: Table.api.formatter.label},
- {field: 'summary', title: __('简介'),operate: "like",formatter: Table.api.formatter.content,width: 200},
- {field: 'info.describe', title: __('套餐信息'),operate: "like",formatter: Table.api.formatter.content,width: 200},
- {field: 'remark', title: __('备注'), operate:'like'},
- {field: 'is_hold', title: __('状态'),formatter: Table.api.formatter.normal,searchList:{0:'正常',1:'预占'}},
- {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter: Table.api.formatter.datetime},
- {field: 'create_time', title: __('上架时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter: Table.api.formatter.datetime},
- {field: 'sort', title: __('Sort'),operate: "BETWEEN"},
- {field: 'admin_id', title: __('上传用户'),operate: "="},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[]},
- ]
- ]
- });
- let setStatus=function (_this,field) {
- let a=layer.load()
- $.post('mobile/batch',{id:_this.attr('data-id'),status:_this.attr('data-value')?0:1,field:field},function (res){
- if(res.code){
- _this.attr('data-value',res.data.status)
- if(res.data.status){
- _this.find('i').removeClass('fa-flip-horizontal text-gray')
- }else{
- _this.find('i').addClass('fa-flip-horizontal text-gray')
- }
- }else{
- layer.msg('操作失败')
- }
- layer.close(a)
- })
- }
- $(document).on('click','.btn-change-top',function (){
- setStatus($(this),'top_time')
- })
- $(document).on('click','.btn-change-rec',function (){
- setStatus($(this),'rec_time')
- })
- $(document).on('click','.btn-set-discount',function (){
- let set=$(this).data('set')
- let select=table.bootstrapTable('getSelections'),
- a=[]
- if(!select.length){
- return
- }
- select.forEach(item=>{
- a.push(item.id)
- })
- if(!set){
- $.post($.fn.bootstrapTable.defaults.extend.cancel_discount,{ids:a},function (){
- layer.msg('操作成功')
- $('.btn-refresh').trigger('click')
- })
- }else{
- Fast.api.open($.fn.bootstrapTable.defaults.extend.set_discount+`/ids/${a.join(',')}`,'设置特价',{
- close(){
- $('.btn-refresh').trigger('click')
- }
- })
- }
- })
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- setdiscount(){
- Controller.api.bindevent();
- $(document).on('click','#activity_forever input',function (){
- if(this.value==0){
- $('input[name="row[activity_time_end]"]').attr('disabled',false)
- }else{
- $('input[name="row[activity_time_end]"]').attr('disabled',true)
- }
- })
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- },
- takeit(){
- Controller.api.bindevent();
- $('.kill-discount-radio').change(function (){
- let amount=$('#c-amount_base').val(),
- dis=this.value
- let total=amount*dis
- $('#c-amount_kill').val(total.toFixed(2))
- })
- $('.kill-discount').bind('input propertychange',function (){
- let amount=$('#c-amount_base').val(),
- dis=this.value
- let total=amount*dis/10
- $('#c-amount_kill').val(total.toFixed(2))
- })
- }
- };
- return Controller;
- });
|