123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'mobile/index' + location.search,
- add_url: 'mobile/add',
- edit_url: 'mobile/edit',
- del_url: 'mobile/del',
- multi_url: 'mobile/multi',
- multi_edit_url: 'mobile/multi_edit',
- multi_edit_proxy_url: 'mobile/multi_edit_proxy',
- multi_edit_status_url: 'mobile/multi_edit_status',
- import_url: 'mobile/import',
- export_url: 'mobile/export',
- batch: 'mobile/batch',
- table: 'mobile',
- cancel_discount: 'mobile/cancelsetdiscount',
- set_discount: 'mobile/setdiscount',
- batch_set_amount: 'mobile/batch_set_amount',
- batch_set_kill: 'mobile/set_kill',
- batch_activity_cancel: 'mobile/batch_activity_cancel',
- }
- });
- var table = $("#table");
- //let status = await $.getJSON('mobile/status')
- let mobileStatus={}
- mobile_status.forEach((item,idx)=>{
- mobileStatus[idx]=item
- })
- $('.btn-multi-edit').click(function (){
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- if(!ids.length){
- layer.alert('请选择')
- return
- }
- Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_url}/ids/${ids.join(',')}`,'批量编辑')
- })
- $('.btn-export').click(function (){
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- if(!ids.length){
- parent.layer.alert('请选择')
- return
- }
- open(`${$.fn.bootstrapTable.defaults.extend.export_url}/ids/${ids.join(',')}`)
- })
- $('.btn-multi-edit-proxy').click(function (){
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- if(!ids.length){
- layer.alert('请选择')
- return
- }
- Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_proxy_url}/ids/${ids.join(',')}`,'编辑供应商')
- })
- $('.btn-multi-edit-status').click(function (){
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- if(!ids.length){
- layer.alert('请选择')
- return
- }
- Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_status_url}/ids/${ids.join(',')}`,'编辑上下架')
- })
- $('.btn-batch_set_amount').click(function (){
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- if(!ids.length){
- layer.alert('请选择')
- return
- }
- Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.batch_set_amount}/ids/${ids.join(',')}`,'批量改价')
- })
- $('.btn-batch_set_kill').click(function (){
- let ids=[]
- $('#table').bootstrapTable('getSelections').forEach(item=>{
- ids.push(item.id)
- })
- if(!ids.length){
- layer.alert('请选择')
- return
- }
- Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.batch_set_kill}/ids/${ids.join(',')}`,'秒杀')
- })
- $('.btn-set_online_clear').click(function (){
- Fast.api.open(`${$(this).data('url')}`,$(this).text())
- })
- let _delete_condition=false,deleteIdx,secpwd
- let make_export
- let sub=admin_Info.is_sub
- let columns= [
- {checkbox: true},
- {field: 'id', title: __('Id'),operate: false,},
- {field: 'no', title: __('手机号'), operate: "LIKE"},
- {field: 'filter_first_last', title: __('筛选位置'),visible: false,operate: '=',searchList: {1:'尾部',2:'中间'},defaultValue:1},
- {field: 'province', title: __('Province'),operate: 'LIKE'},
- {field: 'city', title: __('归属地'),operate: 'LIKE'},
- {field: 'exclude_nums', title: __('排除数字'),visible:false,data:'data-field="title" data-multiple="true" data-source="mobile/exclude_nums" readonly',addclass: 'selectpage'},
- {field: 'network', title: __('运营商'), formatter(network){
- return `<span style="background: ${networkColor[network]};color: white;border-radius: 5px;padding: 3px 6px;">${network}</span>`
- },searchList: mobile_network},
- {field: 'proxy_id', title: __('供应商')/*, searchList: proxy*/,formatter(_,mobile) {
- return mobile.proxy_name;
- }},
- {field: 'brand', title: __('卡品牌'), formatter: Table.api.formatter.label, operate: "LIKE"},
- {
- field: 'rules', title: __('规律'), searchList: Object.keys(filters), formatter(a) {
- return a.join('<br>')
- }
- },
- {
- field: 'info.describe',
- title: __('套餐信息'),
- operate: "like",
- formatter: Table.api.formatter.content,
- width: 200
- },
- {field: 'amount_original', title: __('Amount_original'), operate: false},
- {field: 'amount_di', title: __('底价'), operate: 'BETWEEN'},
- {field: 'amount_proxy', title: __('代理价'), operate: 'BETWEEN'},
- {field: 'amount_base', title: __('Amount'), operate: 'BETWEEN'},
- {field: 'amount_kill', title: __('秒杀价'), operate: 'BETWEEN'},
- {field: 'amount_charge', title: __('预存话费'), operate: 'BETWEEN'},
- {field: 'api_goods_id', title: __('Api商品id')},
- {field: 'remark', title: __('备注'), operate: 'like'},
- {
- //field: sub?'mobile_sub.sub_top_time':'top_time',
- field: 'top_time',
- title: __('Top_time'),
- //operate: 'RANGE',
- //addclass: 'datetimerange',
- autocomplete: false,
- /* formatter(a, b, c) {
- return `<a data-toggle="switcher" class="btn-switcher btn-change-top" data-id="${b.id}" data-value="${a ? a : ''}">
- <i class="fa fa-toggle-on text-success ${a ? '' : 'fa-flip-horizontal text-gray'} fa-2x"></i>
- </a>`
- }*/
- formatter: Table.api.formatter.label,
- /*formatter(a){
- if(a>0){
- return '<span class="label label-success">是</span>'
- }
- return '<span class="label label-default">否</span>'
- },*/
- searchList: {1:'置顶1',2:'置顶2',3:'置顶3',4:'置顶4',5:'置顶5',0:'否'},
- },
- {
- //field: sub?'mobile_sub.sub_rec_time':'rec_time',
- field: 'rec_time',
- title: __('Rec_time'),
- //operate: 'RANGE',
- //addclass: 'datetimerange',
- autocomplete: false,
- /*formatter(a, b, c) {
- return `<a data-toggle="switcher" class="btn-switcher btn-change-rec" data-id="${b.id}" data-value="${a ? a : ''}">
- <i class="fa fa-toggle-on text-success ${a ? '' : 'fa-flip-horizontal text-gray'} fa-2x"></i>
- </a>`
- }*/
- formatter: Table.api.formatter.label,
- /*formatter(a){
- if(a>0){
- return '<span class="label label-success">是</span>'
- }
- return '<span class="label label-default">否</span>'
- },*/
- searchList: {1:'推荐1',2:'推荐2',3:'推荐3',4:'推荐4',5:'推荐5',0:'否'},
- },
- {
- field: 'is_offer',
- title: '特价号',
- autocomplete: false,
- formatter(a){
- if(a>0){
- return '<span class="label label-success">是</span>'
- }
- return '<span class="label label-default">否</span>'
- },
- searchList: {1:'是',0:'否'},
- },
- {
- field: 'buttons',
- width: "120px",
- title: __('操作'),
- table: table,
- events: Table.api.events.operate,
- operate: false,
- formatter: Table.api.formatter.buttons,
- buttons: [
- {
- name: 'detail',
- text: __('预占'),
- title: __('预占'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile/takeit',
- callback: function (data) {
- },
- visible: function (row) {
- return table.data('operate-mobile_takeit') && row.is_activity===0;
- }
- },
- {
- name: 'detail',
- text: __('取消预占'),
- title: __('取消预占'),
- classname: 'btn btn-xs btn-warning btn-ajax',
- confirm: '确认取消吗?',
- url: 'mobile/activity_cancel?aaa=1',
- success: function (data) {
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- return table.data('operate-activity_cancel') && row.is_activity===1;
- },
- disable(row){
- return admin_Info.is_sub && row.hold_chan!==admin_Info.id
- }
- },
- {
- name: 'detail',
- text: __('记录'),
- title: __('记录'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile_price_log/index?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return true;
- }
- },
- ]
- },
- {field: 'status', title: __('号码状态'), formatter (a,b){
- if(b.is_activity){
- return `<span style="color: red"><div>●</div>预占</span>`
- }else{
- return mobileStatus[a]
- }
- }, searchList: mobileStatus},
- {
- 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: sub?'mobile_sub.sub_sort':'sort', title: __('Sort'), operate: "BETWEEN"},
- {field: 'sort', title: __('Sort'), operate: "BETWEEN"},
- {field: 'hold_chan', title: __('预占通道'), operate: "="},
- {field: 'hold_user', title: __('预占用户ID'), operate: "="},
- {field: 'admin_id', title: __('上传用户'), operate: "="},
- {field: 'search_precise', title: __('精准搜索'),visible:false,searchList(){
- return Template('preciseInputs',{})
- }},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- width: 150,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate,
- buttons: [
- {
- name: 'detail',
- text: __('记录'),
- title: __('记录'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile_price_log/index?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return table.data('operate-mobile_price_log');
- }
- },
- {
- name: 'detail',
- text: '排序',
- title: '排序',
- classname: 'btn btn-dialog btn-info btn-xs',
- url: 'mobile/mobile_sort',
- visible(row){
- return table.data('operate-mobile_sort')
- }
- }
- ]
- },
- ]
- if(!admin_Info.is_manager){
- Table.api.removeColumn('proxy_id',columns)
- }
- if(!showAmountDi){
- Table.api.removeColumn('amount_di',columns)
- }
- if(!showAmountProxy){
- Table.api.removeColumn('amount_proxy',columns)
- }
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- search: false,
- searchFormVisible: true,
- fixedColumns: true,
- fixedRightNumber:1,
- columns: [columns],
- onLoadSuccess(data){
- if(data.delete_condition_msg){
- layer.msg(data.delete_condition_msg)
- }
- layer.close(deleteIdx)
- make_export=data.url
- },
- queryParams(params){
- params._delete_condition=_delete_condition
- params.secpwd=secpwd
- let precise_search={}
- for(var i=2;i<=11;i++){
- precise_search[i]=$(`.form-commonsearch input[name="precise[${i}]"]`).val()
- }
- params.precise_search=precise_search
- return params
- }
- });
- $('.btn-add,.btn-edit').data('area',["100%","100%"])
- 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')
- }
- })
- }
- })
- $(document).on('click','.btn-import-disabled',function (){
- let btn=$(this)
- let input=document.createElement('input')
- input.type='file'
- input.accept='.xlsx'
- input.onchange=function (){
- let file=this.files[0]
- let form=new FormData
- form.append('file',file)
- let idx=layer.load()
- $.ajax('/admin.php/ajax/upload',{
- error(){
- layer.alert('上传出错')
- layer.close(idx)
- },
- type:'post',
- contentType:false,
- processData:false,
- data:form,
- success({code,data,msg}){
- if(!code){
- layer.alert(msg)
- }else{
- $.ajax(btn.data('href'),{
- error(){
- layer.alert('导入出错')
- },
- complete(){
- layer.close(idx)
- },
- type:'post',
- data:{file:data.url},
- success({code,data,msg}){
- if(!code){
- layer.alert(msg)
- }else{
- Toastr.success(msg)
- //$('.btn-refresh').trigger('click')
- }
- }
- })
- }
- }
- })
- }
- input.click()
- })
- let next=0,prev=0
- $('.form-commonsearch .preciseInput').bind('input keyup',function (){
- if($(this).val()>9){
- $(this).val($(this).val().substr(0,1))
- }
- if(next===1){
- next=0
- return
- }
- if($(this).val()){
- if(!$(this).next()[0]){
- return
- }
- let tagName=$(this).next()[0].tagName
- if(tagName==='BR'){
- $(this).next().next().focus().select()
- }else {
- $(this).next().focus().select()
- }
- next=1
- }else{
- $(this).prev().focus().select()
- next=1
- }
- })
- let searchForm=$('.form-commonsearch')
- $('.btn-del-condition').click(function (){
- var rows = table.bootstrapTable('getOptions').totalRows;
- parent.layer.prompt(
- {
- title:'如果未选择条件则删除全部号码!',
- formType:1,success(layero){
- layero.find('.layui-layer-input').attr('placeholder','二级密码(本次删除'+rows+'项)')
- }},function (pass,idx){
- parent.layer.close(idx)
- _delete_condition=true
- secpwd=pass
- deleteIdx=layer.load()
- searchForm.find('button[type="submit"]').click()
- _delete_condition=false
- secpwd=null
- })
- })
- $('.btn-del-all').click(function (){
- let href=$(this).data('href')
- parent.layer.prompt({title:'删除全部',formType:1,success(layero){
- layero.find('.layui-layer-input').attr('placeholder','二级密码')
- }},function (pass,idx1){
- parent.layer.close(idx1)
- let idx=layer.load()
- $.ajax(href,{
- type:'post',
- success({code,msg,data}){
- if(code===1){
- let num=data.num||0
- layer.alert(`成功删除${num}个号码`)
- $('.btn-refresh').click()
- }else{
- layer.alert(msg)
- }
- },
- error(){
- layer.alert('请求出错')
- },
- complete(){
- layer.close(idx)
- }
- })
- })
- })
- $('.btn-php-export').click(function (){
- let idx=parent.layer.load(1)
- $.get(make_export,function (res){
- parent.layer.alert(res)
- parent.layer.close(idx)
- })
- })
- window.refresh=()=>{
- $('.btn-refresh').trigger('click')
- }
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- mobile_kill: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'mobile/mobile_kill' + location.search,
- edit_url: 'mobile/edit',
- multi_url: 'mobile/multi',
- batch_activity_cancel: 'mobile/batch_activity_cancel',
- }
- });
- var table = $("#table");
- let mobileStatus={},
- sub=admin_Info.is_sub
- mobile_status.forEach((item,idx)=>{
- mobileStatus[idx]=item
- })
- let columns=[
- {checkbox: true},
- //{field: 'id', title: __('Id')},
- {field: 'no', title: __('手机号'), operate: "LIKE"},
- {field: 'province', title: __('Province'),operate: 'LIKE'},
- {field: 'city', title: __('归属地'),operate: 'LIKE'},
- {field: 'network', title: __('运营商'), formatter(network){
- return `<span style="background: ${networkColor[network]};color: white;border-radius: 5px;padding: 3px 6px;">${network}</span>`
- },searchList: mobile_network},
- {field: 'proxy.nickname', title: __('供应商'), formatter: Table.api.formatter.label,operate: 'LIKE'},
- {field: 'brand', title: __('卡品牌'), formatter: Table.api.formatter.label, operate: "LIKE"},
- {
- field: 'rules', title: __('规律'), searchList: Object.keys(filters), formatter(a) {
- return a.join('<br>')
- }
- },
- {
- field: 'info.describe',
- title: __('套餐信息'),
- operate: "like",
- formatter: Table.api.formatter.content,
- width: 200
- },
- {field: 'amount_original', title: __('Amount_original'), operate: false},
- {field: 'amount_di', title: __('底价'), operate: 'BETWEEN'},
- {field: 'amount_base', title: __('Amount'), operate: 'BETWEEN'},
- {field: 'amount_kill', title: __('秒杀价'), operate: 'BETWEEN'},
- {field: 'amount_charge', title: __('预存话费'), operate: 'BETWEEN'},
- {field: 'remark', title: __('备注'), operate: 'like'},
- {
- //field: sub?'mobile_sub.sub_top_time':'top_time',
- field: 'top_time',
- title: __('Top_time'),
- autocomplete: false,
- formatter: Table.api.formatter.label,
- searchList: {1:'置顶1',2:'置顶2',3:'置顶3',4:'置顶4',5:'置顶5',0:'否'},
- },
- {
- //field: sub?'mobile_sub.sub_rec_time':'rec_time',
- field: 'rec_time',
- title: __('Rec_time'),
- autocomplete: false,
- formatter: Table.api.formatter.label,
- searchList: {1:'推荐1',2:'推荐2',3:'推荐3',4:'推荐4',5:'推荐5',0:'否'},
- },
- //{field: 'is_hold', title: __('预占'),formatter: Table.api.formatter.toggle,searchList:{0:'否',1:'是'}},
- {
- field: 'buttons',
- width: "120px",
- title: __('操作'),
- table: table,
- events: Table.api.events.operate,
- operate: false,
- formatter: Table.api.formatter.buttons,
- buttons: [
- {
- name: 'detail',
- text: __('预占'),
- title: __('预占'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile/takeit',
- callback: function (data) {
- },
- visible: function (row) {
- return table.data('operate-mobile_takeit') && row.is_activity===0;
- }
- },
- {
- name: 'detail',
- text: __('取消预占'),
- title: __('取消预占'),
- classname: 'btn btn-xs btn-warning btn-ajax',
- confirm: '确认取消吗?',
- url: 'mobile/activity_cancel?aaa=1',
- success: function (data) {
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- return table.data('operate-activity_cancel') && row.is_activity===1;
- },
- disable(row){
- return admin_Info.is_sub && row.hold_chan!==admin_Info.id
- }
- },
- {
- name: 'detail',
- text: __('记录'),
- title: __('记录'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile_price_log/index?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return true;
- }
- },
- ]
- },
- {field: 'status', title: __('号码状态'), formatter (a,b){
- if(b.is_activity){
- return `<span style="color: red"><div>●</div>预占</span>`
- }else{
- return mobileStatus[a]
- }
- }, searchList: mobileStatus},
- {
- 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: sub?'mobile_sub.sub_sort':'sort', title: __('Sort'), operate: "BETWEEN"},
- {field: 'sort', title: __('Sort'), operate: "BETWEEN"},
- {field: 'hold_chan', title: __('预占通道'), operate: "="},
- {field: 'hold_user', title: __('预占用户ID'), operate: "="},
- {field: 'admin_id', title: __('上传用户'), operate: "="},
- /*{field: 'name', title: __('Name')},
- {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList:no_type},
- {field: 'amount_exists', title: __('Amount_exists'), operate:'BETWEEN'},
- {field: 'amount_base', title: __('Amount_base'), operate:'BETWEEN'},
- {field: 'summary', title: __('Summary')},
- {field: 'saled', title: __('Saled'),formatter: Table.api.formatter.label,searchList:{0:'否',1:'是'}},
- {field: 'is_activity', title: __('Is_activity'),formatter: Table.api.formatter.label,searchList:{0:'否',1:'是'}},
- {field: 'activity_time_end', title: __('Activity_time_end'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- {field: 'sort', title: __('Sort'),operate: "BETWEEN"},*/
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- width: 150,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate,
- buttons: [
- {
- name: 'detail',
- text: __('记录'),
- title: __('记录'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile_price_log/index?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return true;
- }
- },
- ]
- },
- ]
- if(admin_Info.is_sub){
- Table.api.removeColumn('proxy.nickname',columns)
- }
- if(!showAmountDi){
- Table.api.removeColumn('amount_di',columns)
- }
- if(!showAmountProxy){
- Table.api.removeColumn('amount_proxy',columns)
- }
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- search: false,
- searchFormVisible: true,
- fixedColumns: true,
- fixedRightNumber:1,
- columns: [
- columns
- ]
- });
- 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')
- }
- })
- }
- })
- $(document).on('click', '.btn-batch_activity_cancel', function () {
- let select = table.bootstrapTable('getSelections'),
- a = []
- if (!select.length) {
- return
- }
- select.forEach(item => {
- a.push(item.id)
- })
- layer.confirm('确认取消吗?',function (){
- let idx=layer.load()
- $.post($.fn.bootstrapTable.defaults.extend.batch_activity_cancel, {ids: a}, function () {
- layer.msg('操作成功')
- $('.btn-refresh').trigger('click')
- layer.close(idx)
- })
- })
- })
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- 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(0))
- })
- $('.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(0))
- })
- },
- 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]"));
- }
- },
- multi_edit(){
- Controller.api.bindevent();
- },
- batch_set_amount(){
- Controller.api.bindevent();
- },
- set_kill(){
- Controller.api.bindevent();
- },
- set_online_clear(){
- Controller.api.bindevent();
- $('.btn-check').click(function (){
- let idx=layer.load()
- $.ajax(location.href,{
- type:'post',
- data:{act:'check'},
- success({code,msg,data}){
- if(code===1){
- let num=data.num||0
- $('.btn-check-show').text(`共${num}个重复号码`)
- checkdNum=num
- checked=true
- }else{
- layer.alert(msg)
- }
- },
- error(){
- layer.alert('请求出错')
- },
- complete(){
- layer.close(idx)
- }
- })
- })
- $('.btn-makeDel').click(function (){
- let idx=layer.load()
- $.ajax(location.href,{
- type:'post',
- data:{act:'del',reserve:$('.reserve-field input:radio:checked').val()},
- success({code,msg,data}){
- if(code===1){
- $('.btn-makeDel-show').text('删除成功')
- checkdNum=0
- checked=false
- let num=data.num||0
- layer.alert(`成功删除${num}个号码`)
- }else{
- layer.alert(msg)
- }
- },
- error(){
- layer.alert('请求出错')
- },
- complete(){
- layer.close(idx)
- }
- })
- })
- },
- multi_edit_proxy(){
- Controller.api.bindevent();
- },
- batch_copy_operation(){
- Controller.api.bindevent();
- $(document).on('click','.btn-act',function (){
- let act=$(this).data('act')
- let idx=layer.load()
- $.ajax(location.href,{
- type:'post',
- data:{row:{act:act,no:$('.input-no').val()}},
- success({code,msg,data}){
- if(code===1){
- let num=data.num||0
- layer.alert(`成功操作${num}个号码`)
- parent.refresh()
- }else{
- layer.alert(msg)
- }
- },
- error(){
- layer.alert('请求出错')
- },
- complete(){
- layer.close(idx)
- }
- })
- })
- },
- multi_edit_status(){
- Controller.api.bindevent();
- },
- mobile_sort(){
- Controller.api.bindevent();
- },
- 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(0))
- })
- $('.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(0))
- })
- $('.kill-discount-radio[value="0.8"]').click()
- }
- };
- return Controller;
- });
|