mobile.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: async function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'mobile/index' + location.search,
  8. add_url: 'mobile/add',
  9. edit_url: 'mobile/edit',
  10. del_url: 'mobile/del',
  11. multi_url: 'mobile/multi',
  12. multi_edit_url: 'mobile/multi_edit',
  13. multi_edit_proxy_url: 'mobile/multi_edit_proxy',
  14. multi_edit_status_url: 'mobile/multi_edit_status',
  15. import_url: 'mobile/import',
  16. export_url: 'mobile/export',
  17. batch: 'mobile/batch',
  18. table: 'mobile',
  19. cancel_discount: 'mobile/cancelsetdiscount',
  20. set_discount: 'mobile/setdiscount',
  21. batch_set_amount: 'mobile/batch_set_amount',
  22. batch_set_kill: 'mobile/set_kill',
  23. batch_activity_cancel: 'mobile/batch_activity_cancel',
  24. }
  25. });
  26. var table = $("#table");
  27. //let status = await $.getJSON('mobile/status')
  28. let mobileStatus={}
  29. mobile_status.forEach((item,idx)=>{
  30. mobileStatus[idx]=item
  31. })
  32. $('.btn-multi-edit').click(function (){
  33. let ids=[]
  34. $('#table').bootstrapTable('getSelections').forEach(item=>{
  35. ids.push(item.id)
  36. })
  37. if(!ids.length){
  38. layer.alert('请选择')
  39. return
  40. }
  41. Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_url}/ids/${ids.join(',')}`,'批量编辑')
  42. })
  43. $('.btn-export').click(function (){
  44. let ids=[]
  45. $('#table').bootstrapTable('getSelections').forEach(item=>{
  46. ids.push(item.id)
  47. })
  48. if(!ids.length){
  49. parent.layer.alert('请选择')
  50. return
  51. }
  52. open(`${$.fn.bootstrapTable.defaults.extend.export_url}/ids/${ids.join(',')}`)
  53. })
  54. $('.btn-multi-edit-proxy').click(function (){
  55. let ids=[]
  56. $('#table').bootstrapTable('getSelections').forEach(item=>{
  57. ids.push(item.id)
  58. })
  59. if(!ids.length){
  60. layer.alert('请选择')
  61. return
  62. }
  63. Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_proxy_url}/ids/${ids.join(',')}`,'编辑供应商')
  64. })
  65. $('.btn-multi-edit-status').click(function (){
  66. let ids=[]
  67. $('#table').bootstrapTable('getSelections').forEach(item=>{
  68. ids.push(item.id)
  69. })
  70. if(!ids.length){
  71. layer.alert('请选择')
  72. return
  73. }
  74. Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_status_url}/ids/${ids.join(',')}`,'编辑上下架')
  75. })
  76. $('.btn-batch_set_amount').click(function (){
  77. let ids=[]
  78. $('#table').bootstrapTable('getSelections').forEach(item=>{
  79. ids.push(item.id)
  80. })
  81. if(!ids.length){
  82. layer.alert('请选择')
  83. return
  84. }
  85. Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.batch_set_amount}/ids/${ids.join(',')}`,'批量改价')
  86. })
  87. $('.btn-batch_set_kill').click(function (){
  88. let ids=[]
  89. $('#table').bootstrapTable('getSelections').forEach(item=>{
  90. ids.push(item.id)
  91. })
  92. if(!ids.length){
  93. layer.alert('请选择')
  94. return
  95. }
  96. Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.batch_set_kill}/ids/${ids.join(',')}`,'秒杀')
  97. })
  98. $('.btn-set_online_clear').click(function (){
  99. Fast.api.open(`${$(this).data('url')}`,$(this).text())
  100. })
  101. let _delete_condition=false,deleteIdx,secpwd
  102. let make_export
  103. let sub=admin_Info.is_sub
  104. let columns= [
  105. {checkbox: true},
  106. {field: 'id', title: __('Id'),operate: false,},
  107. {field: 'no', title: __('手机号'), operate: "LIKE"},
  108. {field: 'filter_first_last', title: __('筛选位置'),visible: false,operate: '=',searchList: {1:'尾部',2:'中间'},defaultValue:1},
  109. {field: 'province', title: __('Province'),operate: 'LIKE'},
  110. {field: 'city', title: __('归属地'),operate: 'LIKE'},
  111. {field: 'exclude_nums', title: __('排除数字'),visible:false,data:'data-field="title" data-multiple="true" data-source="mobile/exclude_nums" readonly',addclass: 'selectpage'},
  112. {field: 'network', title: __('运营商'), formatter(network){
  113. return `<span style="background: ${networkColor[network]};color: white;border-radius: 5px;padding: 3px 6px;">${network}</span>`
  114. },searchList: mobile_network},
  115. {field: 'proxy_id', title: __('供应商')/*, searchList: proxy*/,formatter(_,mobile) {
  116. return mobile.proxy_name;
  117. }},
  118. {field: 'brand', title: __('卡品牌'), formatter: Table.api.formatter.label, operate: "LIKE"},
  119. {
  120. field: 'rules', title: __('规律'), searchList: Object.keys(filters), formatter(a) {
  121. return a.join('<br>')
  122. }
  123. },
  124. {
  125. field: 'info.describe',
  126. title: __('套餐信息'),
  127. operate: "like",
  128. formatter: Table.api.formatter.content,
  129. width: 200
  130. },
  131. {field: 'amount_original', title: __('Amount_original'), operate: false},
  132. {field: 'amount_di', title: __('底价'), operate: 'BETWEEN'},
  133. {field: 'amount_proxy', title: __('代理价'), operate: 'BETWEEN'},
  134. {field: 'amount_base', title: __('Amount'), operate: 'BETWEEN'},
  135. {field: 'amount_kill', title: __('秒杀价'), operate: 'BETWEEN'},
  136. {field: 'amount_charge', title: __('预存话费'), operate: 'BETWEEN'},
  137. {field: 'api_goods_id', title: __('Api商品id')},
  138. {field: 'remark', title: __('备注'), operate: 'like'},
  139. {
  140. //field: sub?'mobile_sub.sub_top_time':'top_time',
  141. field: 'top_time',
  142. title: __('Top_time'),
  143. //operate: 'RANGE',
  144. //addclass: 'datetimerange',
  145. autocomplete: false,
  146. /* formatter(a, b, c) {
  147. return `<a data-toggle="switcher" class="btn-switcher btn-change-top" data-id="${b.id}" data-value="${a ? a : ''}">
  148. <i class="fa fa-toggle-on text-success ${a ? '' : 'fa-flip-horizontal text-gray'} fa-2x"></i>
  149. </a>`
  150. }*/
  151. formatter: Table.api.formatter.label,
  152. /*formatter(a){
  153. if(a>0){
  154. return '<span class="label label-success">是</span>'
  155. }
  156. return '<span class="label label-default">否</span>'
  157. },*/
  158. searchList: {1:'置顶1',2:'置顶2',3:'置顶3',4:'置顶4',5:'置顶5',0:'否'},
  159. },
  160. {
  161. //field: sub?'mobile_sub.sub_rec_time':'rec_time',
  162. field: 'rec_time',
  163. title: __('Rec_time'),
  164. //operate: 'RANGE',
  165. //addclass: 'datetimerange',
  166. autocomplete: false,
  167. /*formatter(a, b, c) {
  168. return `<a data-toggle="switcher" class="btn-switcher btn-change-rec" data-id="${b.id}" data-value="${a ? a : ''}">
  169. <i class="fa fa-toggle-on text-success ${a ? '' : 'fa-flip-horizontal text-gray'} fa-2x"></i>
  170. </a>`
  171. }*/
  172. formatter: Table.api.formatter.label,
  173. /*formatter(a){
  174. if(a>0){
  175. return '<span class="label label-success">是</span>'
  176. }
  177. return '<span class="label label-default">否</span>'
  178. },*/
  179. searchList: {1:'推荐1',2:'推荐2',3:'推荐3',4:'推荐4',5:'推荐5',0:'否'},
  180. },
  181. {
  182. field: 'is_offer',
  183. title: '特价号',
  184. autocomplete: false,
  185. formatter(a){
  186. if(a>0){
  187. return '<span class="label label-success">是</span>'
  188. }
  189. return '<span class="label label-default">否</span>'
  190. },
  191. searchList: {1:'是',0:'否'},
  192. },
  193. {
  194. field: 'buttons',
  195. width: "120px",
  196. title: __('操作'),
  197. table: table,
  198. events: Table.api.events.operate,
  199. operate: false,
  200. formatter: Table.api.formatter.buttons,
  201. buttons: [
  202. {
  203. name: 'detail',
  204. text: __('预占'),
  205. title: __('预占'),
  206. classname: 'btn btn-xs btn-info btn-dialog',
  207. url: 'mobile/takeit',
  208. callback: function (data) {
  209. },
  210. visible: function (row) {
  211. return table.data('operate-mobile_takeit') && row.is_activity===0;
  212. }
  213. },
  214. {
  215. name: 'detail',
  216. text: __('取消预占'),
  217. title: __('取消预占'),
  218. classname: 'btn btn-xs btn-warning btn-ajax',
  219. confirm: '确认取消吗?',
  220. url: 'mobile/activity_cancel?aaa=1',
  221. success: function (data) {
  222. $('.btn-refresh').trigger('click')
  223. },
  224. visible: function (row) {
  225. return table.data('operate-activity_cancel') && row.is_activity===1;
  226. },
  227. disable(row){
  228. return admin_Info.is_sub && row.hold_chan!==admin_Info.id
  229. }
  230. },
  231. {
  232. name: 'detail',
  233. text: __('记录'),
  234. title: __('记录'),
  235. classname: 'btn btn-xs btn-info btn-dialog',
  236. url: 'mobile_price_log/index?a=1',
  237. callback: function (data) {
  238. },
  239. visible: function (row) {
  240. return true;
  241. }
  242. },
  243. ]
  244. },
  245. {field: 'status', title: __('号码状态'), formatter (a,b){
  246. if(b.is_activity){
  247. return `<span style="color: red"><div>●</div>预占</span>`
  248. }else{
  249. return mobileStatus[a]
  250. }
  251. }, searchList: mobileStatus},
  252. {
  253. field: 'update_time',
  254. title: __('Update_time'),
  255. operate: 'RANGE',
  256. addclass: 'datetimerange',
  257. autocomplete: false,
  258. formatter: Table.api.formatter.datetime
  259. },
  260. {
  261. field: 'create_time',
  262. title: __('上架时间'),
  263. operate: 'RANGE',
  264. addclass: 'datetimerange',
  265. autocomplete: false,
  266. formatter: Table.api.formatter.datetime
  267. },
  268. //{field: sub?'mobile_sub.sub_sort':'sort', title: __('Sort'), operate: "BETWEEN"},
  269. {field: 'sort', title: __('Sort'), operate: "BETWEEN"},
  270. {field: 'hold_chan', title: __('预占通道'), operate: "="},
  271. {field: 'hold_user', title: __('预占用户ID'), operate: "="},
  272. {field: 'admin_id', title: __('上传用户'), operate: "="},
  273. {field: 'search_precise', title: __('精准搜索'),visible:false,searchList(){
  274. return Template('preciseInputs',{})
  275. }},
  276. {
  277. field: 'operate',
  278. title: __('Operate'),
  279. table: table,
  280. width: 150,
  281. events: Table.api.events.operate,
  282. formatter: Table.api.formatter.operate,
  283. buttons: [
  284. {
  285. name: 'detail',
  286. text: __('记录'),
  287. title: __('记录'),
  288. classname: 'btn btn-xs btn-info btn-dialog',
  289. url: 'mobile_price_log/index?a=1',
  290. callback: function (data) {
  291. },
  292. visible: function (row) {
  293. return table.data('operate-mobile_price_log');
  294. }
  295. },
  296. {
  297. name: 'detail',
  298. text: '排序',
  299. title: '排序',
  300. classname: 'btn btn-dialog btn-info btn-xs',
  301. url: 'mobile/mobile_sort',
  302. visible(row){
  303. return table.data('operate-mobile_sort')
  304. }
  305. }
  306. ]
  307. },
  308. ]
  309. if(!admin_Info.is_manager){
  310. Table.api.removeColumn('proxy_id',columns)
  311. }
  312. if(!showAmountDi){
  313. Table.api.removeColumn('amount_di',columns)
  314. }
  315. if(!showAmountProxy){
  316. Table.api.removeColumn('amount_proxy',columns)
  317. }
  318. // 初始化表格
  319. table.bootstrapTable({
  320. url: $.fn.bootstrapTable.defaults.extend.index_url,
  321. pk: 'id',
  322. sortName: 'id',
  323. search: false,
  324. searchFormVisible: true,
  325. fixedColumns: true,
  326. fixedRightNumber:1,
  327. columns: [columns],
  328. onLoadSuccess(data){
  329. if(data.delete_condition_msg){
  330. layer.msg(data.delete_condition_msg)
  331. }
  332. layer.close(deleteIdx)
  333. make_export=data.url
  334. },
  335. queryParams(params){
  336. params._delete_condition=_delete_condition
  337. params.secpwd=secpwd
  338. let precise_search={}
  339. for(var i=2;i<=11;i++){
  340. precise_search[i]=$(`.form-commonsearch input[name="precise[${i}]"]`).val()
  341. }
  342. params.precise_search=precise_search
  343. return params
  344. }
  345. });
  346. $('.btn-add,.btn-edit').data('area',["100%","100%"])
  347. let setStatus = function (_this, field) {
  348. let a = layer.load()
  349. $.post('mobile/batch', {
  350. id: _this.attr('data-id'),
  351. status: _this.attr('data-value') ? 0 : 1,
  352. field: field
  353. }, function (res) {
  354. if (res.code) {
  355. _this.attr('data-value', res.data.status)
  356. if (res.data.status) {
  357. _this.find('i').removeClass('fa-flip-horizontal text-gray')
  358. } else {
  359. _this.find('i').addClass('fa-flip-horizontal text-gray')
  360. }
  361. } else {
  362. layer.msg('操作失败')
  363. }
  364. layer.close(a)
  365. })
  366. }
  367. $(document).on('click', '.btn-change-top', function () {
  368. setStatus($(this), 'top_time')
  369. })
  370. $(document).on('click', '.btn-change-rec', function () {
  371. setStatus($(this), 'rec_time')
  372. })
  373. $(document).on('click', '.btn-set-discount', function () {
  374. let set = $(this).data('set')
  375. let select = table.bootstrapTable('getSelections'),
  376. a = []
  377. if (!select.length) {
  378. return
  379. }
  380. select.forEach(item => {
  381. a.push(item.id)
  382. })
  383. if (!set) {
  384. $.post($.fn.bootstrapTable.defaults.extend.cancel_discount, {ids: a}, function () {
  385. layer.msg('操作成功')
  386. $('.btn-refresh').trigger('click')
  387. })
  388. } else {
  389. Fast.api.open($.fn.bootstrapTable.defaults.extend.set_discount + `/ids/${a.join(',')}`, '设置特价', {
  390. close() {
  391. $('.btn-refresh').trigger('click')
  392. }
  393. })
  394. }
  395. })
  396. $(document).on('click','.btn-import-disabled',function (){
  397. let btn=$(this)
  398. let input=document.createElement('input')
  399. input.type='file'
  400. input.accept='.xlsx'
  401. input.onchange=function (){
  402. let file=this.files[0]
  403. let form=new FormData
  404. form.append('file',file)
  405. let idx=layer.load()
  406. $.ajax('/admin.php/ajax/upload',{
  407. error(){
  408. layer.alert('上传出错')
  409. layer.close(idx)
  410. },
  411. type:'post',
  412. contentType:false,
  413. processData:false,
  414. data:form,
  415. success({code,data,msg}){
  416. if(!code){
  417. layer.alert(msg)
  418. }else{
  419. $.ajax(btn.data('href'),{
  420. error(){
  421. layer.alert('导入出错')
  422. },
  423. complete(){
  424. layer.close(idx)
  425. },
  426. type:'post',
  427. data:{file:data.url},
  428. success({code,data,msg}){
  429. if(!code){
  430. layer.alert(msg)
  431. }else{
  432. Toastr.success(msg)
  433. //$('.btn-refresh').trigger('click')
  434. }
  435. }
  436. })
  437. }
  438. }
  439. })
  440. }
  441. input.click()
  442. })
  443. let next=0,prev=0
  444. $('.form-commonsearch .preciseInput').bind('input keyup',function (){
  445. if($(this).val()>9){
  446. $(this).val($(this).val().substr(0,1))
  447. }
  448. if(next===1){
  449. next=0
  450. return
  451. }
  452. if($(this).val()){
  453. if(!$(this).next()[0]){
  454. return
  455. }
  456. let tagName=$(this).next()[0].tagName
  457. if(tagName==='BR'){
  458. $(this).next().next().focus().select()
  459. }else {
  460. $(this).next().focus().select()
  461. }
  462. next=1
  463. }else{
  464. $(this).prev().focus().select()
  465. next=1
  466. }
  467. })
  468. let searchForm=$('.form-commonsearch')
  469. $('.btn-del-condition').click(function (){
  470. var rows = table.bootstrapTable('getOptions').totalRows;
  471. parent.layer.prompt(
  472. {
  473. title:'如果未选择条件则删除全部号码!',
  474. formType:1,success(layero){
  475. layero.find('.layui-layer-input').attr('placeholder','二级密码(本次删除'+rows+'项)')
  476. }},function (pass,idx){
  477. parent.layer.close(idx)
  478. _delete_condition=true
  479. secpwd=pass
  480. deleteIdx=layer.load()
  481. searchForm.find('button[type="submit"]').click()
  482. _delete_condition=false
  483. secpwd=null
  484. })
  485. })
  486. $('.btn-del-all').click(function (){
  487. let href=$(this).data('href')
  488. parent.layer.prompt({title:'删除全部',formType:1,success(layero){
  489. layero.find('.layui-layer-input').attr('placeholder','二级密码')
  490. }},function (pass,idx1){
  491. parent.layer.close(idx1)
  492. let idx=layer.load()
  493. $.ajax(href,{
  494. type:'post',
  495. success({code,msg,data}){
  496. if(code===1){
  497. let num=data.num||0
  498. layer.alert(`成功删除${num}个号码`)
  499. $('.btn-refresh').click()
  500. }else{
  501. layer.alert(msg)
  502. }
  503. },
  504. error(){
  505. layer.alert('请求出错')
  506. },
  507. complete(){
  508. layer.close(idx)
  509. }
  510. })
  511. })
  512. })
  513. $('.btn-php-export').click(function (){
  514. let idx=parent.layer.load(1)
  515. $.get(make_export,function (res){
  516. parent.layer.alert(res)
  517. parent.layer.close(idx)
  518. })
  519. })
  520. window.refresh=()=>{
  521. $('.btn-refresh').trigger('click')
  522. }
  523. // 为表格绑定事件
  524. Table.api.bindevent(table);
  525. },
  526. mobile_kill: async function () {
  527. // 初始化表格参数配置
  528. Table.api.init({
  529. extend: {
  530. index_url: 'mobile/mobile_kill' + location.search,
  531. edit_url: 'mobile/edit',
  532. multi_url: 'mobile/multi',
  533. batch_activity_cancel: 'mobile/batch_activity_cancel',
  534. }
  535. });
  536. var table = $("#table");
  537. let mobileStatus={},
  538. sub=admin_Info.is_sub
  539. mobile_status.forEach((item,idx)=>{
  540. mobileStatus[idx]=item
  541. })
  542. let columns=[
  543. {checkbox: true},
  544. //{field: 'id', title: __('Id')},
  545. {field: 'no', title: __('手机号'), operate: "LIKE"},
  546. {field: 'province', title: __('Province'),operate: 'LIKE'},
  547. {field: 'city', title: __('归属地'),operate: 'LIKE'},
  548. {field: 'network', title: __('运营商'), formatter(network){
  549. return `<span style="background: ${networkColor[network]};color: white;border-radius: 5px;padding: 3px 6px;">${network}</span>`
  550. },searchList: mobile_network},
  551. {field: 'proxy.nickname', title: __('供应商'), formatter: Table.api.formatter.label,operate: 'LIKE'},
  552. {field: 'brand', title: __('卡品牌'), formatter: Table.api.formatter.label, operate: "LIKE"},
  553. {
  554. field: 'rules', title: __('规律'), searchList: Object.keys(filters), formatter(a) {
  555. return a.join('<br>')
  556. }
  557. },
  558. {
  559. field: 'info.describe',
  560. title: __('套餐信息'),
  561. operate: "like",
  562. formatter: Table.api.formatter.content,
  563. width: 200
  564. },
  565. {field: 'amount_original', title: __('Amount_original'), operate: false},
  566. {field: 'amount_di', title: __('底价'), operate: 'BETWEEN'},
  567. {field: 'amount_base', title: __('Amount'), operate: 'BETWEEN'},
  568. {field: 'amount_kill', title: __('秒杀价'), operate: 'BETWEEN'},
  569. {field: 'amount_charge', title: __('预存话费'), operate: 'BETWEEN'},
  570. {field: 'remark', title: __('备注'), operate: 'like'},
  571. {
  572. //field: sub?'mobile_sub.sub_top_time':'top_time',
  573. field: 'top_time',
  574. title: __('Top_time'),
  575. autocomplete: false,
  576. formatter: Table.api.formatter.label,
  577. searchList: {1:'置顶1',2:'置顶2',3:'置顶3',4:'置顶4',5:'置顶5',0:'否'},
  578. },
  579. {
  580. //field: sub?'mobile_sub.sub_rec_time':'rec_time',
  581. field: 'rec_time',
  582. title: __('Rec_time'),
  583. autocomplete: false,
  584. formatter: Table.api.formatter.label,
  585. searchList: {1:'推荐1',2:'推荐2',3:'推荐3',4:'推荐4',5:'推荐5',0:'否'},
  586. },
  587. //{field: 'is_hold', title: __('预占'),formatter: Table.api.formatter.toggle,searchList:{0:'否',1:'是'}},
  588. {
  589. field: 'buttons',
  590. width: "120px",
  591. title: __('操作'),
  592. table: table,
  593. events: Table.api.events.operate,
  594. operate: false,
  595. formatter: Table.api.formatter.buttons,
  596. buttons: [
  597. {
  598. name: 'detail',
  599. text: __('预占'),
  600. title: __('预占'),
  601. classname: 'btn btn-xs btn-info btn-dialog',
  602. url: 'mobile/takeit',
  603. callback: function (data) {
  604. },
  605. visible: function (row) {
  606. return table.data('operate-mobile_takeit') && row.is_activity===0;
  607. }
  608. },
  609. {
  610. name: 'detail',
  611. text: __('取消预占'),
  612. title: __('取消预占'),
  613. classname: 'btn btn-xs btn-warning btn-ajax',
  614. confirm: '确认取消吗?',
  615. url: 'mobile/activity_cancel?aaa=1',
  616. success: function (data) {
  617. $('.btn-refresh').trigger('click')
  618. },
  619. visible: function (row) {
  620. return table.data('operate-activity_cancel') && row.is_activity===1;
  621. },
  622. disable(row){
  623. return admin_Info.is_sub && row.hold_chan!==admin_Info.id
  624. }
  625. },
  626. {
  627. name: 'detail',
  628. text: __('记录'),
  629. title: __('记录'),
  630. classname: 'btn btn-xs btn-info btn-dialog',
  631. url: 'mobile_price_log/index?a=1',
  632. callback: function (data) {
  633. },
  634. visible: function (row) {
  635. return true;
  636. }
  637. },
  638. ]
  639. },
  640. {field: 'status', title: __('号码状态'), formatter (a,b){
  641. if(b.is_activity){
  642. return `<span style="color: red"><div>●</div>预占</span>`
  643. }else{
  644. return mobileStatus[a]
  645. }
  646. }, searchList: mobileStatus},
  647. {
  648. field: 'update_time',
  649. title: __('Update_time'),
  650. operate: 'RANGE',
  651. addclass: 'datetimerange',
  652. autocomplete: false,
  653. formatter: Table.api.formatter.datetime
  654. },
  655. {
  656. field: 'create_time',
  657. title: __('上架时间'),
  658. operate: 'RANGE',
  659. addclass: 'datetimerange',
  660. autocomplete: false,
  661. formatter: Table.api.formatter.datetime
  662. },
  663. //{field: sub?'mobile_sub.sub_sort':'sort', title: __('Sort'), operate: "BETWEEN"},
  664. {field: 'sort', title: __('Sort'), operate: "BETWEEN"},
  665. {field: 'hold_chan', title: __('预占通道'), operate: "="},
  666. {field: 'hold_user', title: __('预占用户ID'), operate: "="},
  667. {field: 'admin_id', title: __('上传用户'), operate: "="},
  668. /*{field: 'name', title: __('Name')},
  669. {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList:no_type},
  670. {field: 'amount_exists', title: __('Amount_exists'), operate:'BETWEEN'},
  671. {field: 'amount_base', title: __('Amount_base'), operate:'BETWEEN'},
  672. {field: 'summary', title: __('Summary')},
  673. {field: 'saled', title: __('Saled'),formatter: Table.api.formatter.label,searchList:{0:'否',1:'是'}},
  674. {field: 'is_activity', title: __('Is_activity'),formatter: Table.api.formatter.label,searchList:{0:'否',1:'是'}},
  675. {field: 'activity_time_end', title: __('Activity_time_end'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  676. {field: 'sort', title: __('Sort'),operate: "BETWEEN"},*/
  677. {
  678. field: 'operate',
  679. title: __('Operate'),
  680. table: table,
  681. width: 150,
  682. events: Table.api.events.operate,
  683. formatter: Table.api.formatter.operate,
  684. buttons: [
  685. {
  686. name: 'detail',
  687. text: __('记录'),
  688. title: __('记录'),
  689. classname: 'btn btn-xs btn-info btn-dialog',
  690. url: 'mobile_price_log/index?a=1',
  691. callback: function (data) {
  692. },
  693. visible: function (row) {
  694. return true;
  695. }
  696. },
  697. ]
  698. },
  699. ]
  700. if(admin_Info.is_sub){
  701. Table.api.removeColumn('proxy.nickname',columns)
  702. }
  703. if(!showAmountDi){
  704. Table.api.removeColumn('amount_di',columns)
  705. }
  706. if(!showAmountProxy){
  707. Table.api.removeColumn('amount_proxy',columns)
  708. }
  709. // 初始化表格
  710. table.bootstrapTable({
  711. url: $.fn.bootstrapTable.defaults.extend.index_url,
  712. pk: 'id',
  713. sortName: 'id',
  714. search: false,
  715. searchFormVisible: true,
  716. fixedColumns: true,
  717. fixedRightNumber:1,
  718. columns: [
  719. columns
  720. ]
  721. });
  722. let setStatus = function (_this, field) {
  723. let a = layer.load()
  724. $.post('mobile/batch', {
  725. id: _this.attr('data-id'),
  726. status: _this.attr('data-value') ? 0 : 1,
  727. field: field
  728. }, function (res) {
  729. if (res.code) {
  730. _this.attr('data-value', res.data.status)
  731. if (res.data.status) {
  732. _this.find('i').removeClass('fa-flip-horizontal text-gray')
  733. } else {
  734. _this.find('i').addClass('fa-flip-horizontal text-gray')
  735. }
  736. } else {
  737. layer.msg('操作失败')
  738. }
  739. layer.close(a)
  740. })
  741. }
  742. $(document).on('click', '.btn-change-top', function () {
  743. setStatus($(this), 'top_time')
  744. })
  745. $(document).on('click', '.btn-change-rec', function () {
  746. setStatus($(this), 'rec_time')
  747. })
  748. $(document).on('click', '.btn-set-discount', function () {
  749. let set = $(this).data('set')
  750. let select = table.bootstrapTable('getSelections'),
  751. a = []
  752. if (!select.length) {
  753. return
  754. }
  755. select.forEach(item => {
  756. a.push(item.id)
  757. })
  758. if (!set) {
  759. $.post($.fn.bootstrapTable.defaults.extend.cancel_discount, {ids: a}, function () {
  760. layer.msg('操作成功')
  761. $('.btn-refresh').trigger('click')
  762. })
  763. } else {
  764. Fast.api.open($.fn.bootstrapTable.defaults.extend.set_discount + `/ids/${a.join(',')}`, '设置特价', {
  765. close() {
  766. $('.btn-refresh').trigger('click')
  767. }
  768. })
  769. }
  770. })
  771. $(document).on('click', '.btn-batch_activity_cancel', function () {
  772. let select = table.bootstrapTable('getSelections'),
  773. a = []
  774. if (!select.length) {
  775. return
  776. }
  777. select.forEach(item => {
  778. a.push(item.id)
  779. })
  780. layer.confirm('确认取消吗?',function (){
  781. let idx=layer.load()
  782. $.post($.fn.bootstrapTable.defaults.extend.batch_activity_cancel, {ids: a}, function () {
  783. layer.msg('操作成功')
  784. $('.btn-refresh').trigger('click')
  785. layer.close(idx)
  786. })
  787. })
  788. })
  789. // 为表格绑定事件
  790. Table.api.bindevent(table);
  791. },
  792. add: function () {
  793. Controller.api.bindevent();
  794. },
  795. edit: function () {
  796. Controller.api.bindevent();
  797. $('.kill-discount-radio').change(function (){
  798. let amount=$('#c-amount_base').val(),
  799. dis=this.value
  800. let total=amount*dis
  801. $('#c-amount_kill').val(total.toFixed(0))
  802. })
  803. $('.kill-discount').bind('input propertychange',function (){
  804. let amount=$('#c-amount_base').val(),
  805. dis=this.value
  806. let total=amount*dis/10
  807. $('#c-amount_kill').val(total.toFixed(0))
  808. })
  809. },
  810. setdiscount(){
  811. Controller.api.bindevent();
  812. $(document).on('click','#activity_forever input',function (){
  813. if(this.value==0){
  814. $('input[name="row[activity_time_end]"]').attr('disabled',false)
  815. }else{
  816. $('input[name="row[activity_time_end]"]').attr('disabled',true)
  817. }
  818. })
  819. },
  820. api: {
  821. bindevent: function () {
  822. Form.api.bindevent($("form[role=form]"));
  823. }
  824. },
  825. multi_edit(){
  826. Controller.api.bindevent();
  827. },
  828. batch_set_amount(){
  829. Controller.api.bindevent();
  830. },
  831. set_kill(){
  832. Controller.api.bindevent();
  833. },
  834. set_online_clear(){
  835. Controller.api.bindevent();
  836. $('.btn-check').click(function (){
  837. let idx=layer.load()
  838. $.ajax(location.href,{
  839. type:'post',
  840. data:{act:'check'},
  841. success({code,msg,data}){
  842. if(code===1){
  843. let num=data.num||0
  844. $('.btn-check-show').text(`共${num}个重复号码`)
  845. checkdNum=num
  846. checked=true
  847. }else{
  848. layer.alert(msg)
  849. }
  850. },
  851. error(){
  852. layer.alert('请求出错')
  853. },
  854. complete(){
  855. layer.close(idx)
  856. }
  857. })
  858. })
  859. $('.btn-makeDel').click(function (){
  860. let idx=layer.load()
  861. $.ajax(location.href,{
  862. type:'post',
  863. data:{act:'del',reserve:$('.reserve-field input:radio:checked').val()},
  864. success({code,msg,data}){
  865. if(code===1){
  866. $('.btn-makeDel-show').text('删除成功')
  867. checkdNum=0
  868. checked=false
  869. let num=data.num||0
  870. layer.alert(`成功删除${num}个号码`)
  871. }else{
  872. layer.alert(msg)
  873. }
  874. },
  875. error(){
  876. layer.alert('请求出错')
  877. },
  878. complete(){
  879. layer.close(idx)
  880. }
  881. })
  882. })
  883. },
  884. multi_edit_proxy(){
  885. Controller.api.bindevent();
  886. },
  887. batch_copy_operation(){
  888. Controller.api.bindevent();
  889. $(document).on('click','.btn-act',function (){
  890. let act=$(this).data('act')
  891. let idx=layer.load()
  892. $.ajax(location.href,{
  893. type:'post',
  894. data:{row:{act:act,no:$('.input-no').val()}},
  895. success({code,msg,data}){
  896. if(code===1){
  897. let num=data.num||0
  898. layer.alert(`成功操作${num}个号码`)
  899. parent.refresh()
  900. }else{
  901. layer.alert(msg)
  902. }
  903. },
  904. error(){
  905. layer.alert('请求出错')
  906. },
  907. complete(){
  908. layer.close(idx)
  909. }
  910. })
  911. })
  912. },
  913. multi_edit_status(){
  914. Controller.api.bindevent();
  915. },
  916. mobile_sort(){
  917. Controller.api.bindevent();
  918. },
  919. takeit(){
  920. Controller.api.bindevent();
  921. $('.kill-discount-radio').change(function (){
  922. let amount=$('#c-amount_base').val(),
  923. dis=this.value
  924. let total=amount*dis
  925. $('#c-amount_kill').val(total.toFixed(0))
  926. })
  927. $('.kill-discount').bind('input propertychange',function (){
  928. let amount=$('#c-amount_base').val(),
  929. dis=this.value
  930. let total=amount*dis/10
  931. $('#c-amount_kill').val(total.toFixed(0))
  932. })
  933. $('.kill-discount-radio[value="0.8"]').click()
  934. }
  935. };
  936. return Controller;
  937. });