stock.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'stock/index' + location.search,
  8. add_url: 'stock/add',
  9. edit_url: 'stock/edit',
  10. del_url: 'stock/del',
  11. multi_url: 'stock/multi',
  12. import_url: 'stock/import',
  13. table: 'stock',
  14. }
  15. });
  16. var table = $("#table");//index.html table的id
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. rowStyle:Controller.api.rowStyle,
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. {field: 'name', title: __('Name'), operate: 'LIKE'},
  28. {field: 'unit', title: __('Unit'), operate: 'LIKE'},
  29. {field: 'number', title: __('Number'), operate: 'LIKE'},
  30. {field: 'l_number', title: __('L_number'), operate: 'LIKE'},
  31. {field: 'specs', title: __('Specs'), operate: 'LIKE'},
  32. // {field: 'company_id', title: __('Company_id')},
  33. {field: 'create', title: __('Create'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  34. {field: 'update', title: __('Update'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ]
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. $.ajax({
  42. type: "POST",
  43. url: "order/stockad",
  44. success(res) {//根据订单管理返回的值为1代表有新增数据订单
  45. if(res== 1){
  46. layer.confirm("您好,来新订单了!", {
  47. title: ['信息'],
  48. btn: ['确认'],
  49. area: ['60%', '60%'],
  50. },function(index) { //点击处理停止语音播报
  51. setInterval(fn,3000);
  52. jQuery.ajax({
  53. type: "post",
  54. url: "stock/orderstu",
  55. data: {orderstu:2},
  56. success: function(data){//成功回调函数
  57. if(data='处理成功'){
  58. location.reload();//刷新本页面
  59. }
  60. layer.close(index);//点击确定关闭弹窗
  61. },
  62. error: function(){ //失败返回调用
  63. alert("处理异常!");
  64. }
  65. });
  66. });
  67. var fn = function(){//有订单弹出提示框并且语音播报
  68. var synth = window.speechSynthesis;
  69. var msg = new window.SpeechSynthesisUtterance('您好,来新订单了!');
  70. window.speechSynthesis.cancel();
  71. synth.speak(msg);
  72. };
  73. setInterval(fn,5000);//多久播一次
  74. }else{
  75. }
  76. }
  77. });
  78. },
  79. add: function () {
  80. Controller.api.bindevent();
  81. },
  82. edit: function () {
  83. Controller.api.bindevent();
  84. },
  85. api: {
  86. bindevent: function () {
  87. Form.api.bindevent($("form[role=form]"));
  88. },
  89. rowStyle:function(row,index){
  90. var style = {};
  91. if(row.warning){
  92. style={css:{'color':'#ff0000'}};
  93. }
  94. return style;
  95. }
  96. }
  97. };
  98. return Controller;
  99. });