| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'stock/index' + location.search,
- add_url: 'stock/add',
- edit_url: 'stock/edit',
- del_url: 'stock/del',
- multi_url: 'stock/multi',
- import_url: 'stock/import',
- table: 'stock',
- }
- });
- var table = $("#table");//index.html table的id
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- rowStyle:Controller.api.rowStyle,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'name', title: __('Name'), operate: 'LIKE'},
- {field: 'unit', title: __('Unit'), operate: 'LIKE'},
- {field: 'number', title: __('Number'), operate: 'LIKE'},
- {field: 'l_number', title: __('L_number'), operate: 'LIKE'},
- {field: 'specs', title: __('Specs'), operate: 'LIKE'},
- // {field: 'company_id', title: __('Company_id')},
- {field: 'create', title: __('Create'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- {field: 'update', title: __('Update'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- var ref = setInterval(function(){ //定时刷新
- $.ajax({
- type: "POST",
- url: "order/stockad",
- success(res) {//根据订单管理返回的值为1代表有新增数据订单
- if (res == 1) {
- window.clearInterval(ref);//停止刷新
- layer.confirm("您好,来新订单了!", {
- title: ['信息'],
- btn: ['确认'],
- area: ['60%', '60%'],
- },function(index) { //点击处理停止语音播报
- setInterval(fn,3000);
- jQuery.ajax({
- type: "post",
- url: "stock/orderstu",
- data: {orderstu:2},
- success: function(data){//成功回调函数
- if(data='处理成功'){
- location.reload();//刷新本页面
- }
- layer.close(index);//点击确定关闭弹窗
- },
- error: function(){ //失败返回调用
- alert("网络异常!");
- }
- });
- });
- var fn = function(){//有订单弹出提示框并且语音播报
- var synth = window.speechSynthesis;
- var msg = new window.SpeechSynthesisUtterance('您好,来新订单了!');
- window.speechSynthesis.cancel();
- synth.speak(msg);
- };
- setInterval(fn,5000);//多久播一次
- }
- }
- });
- },10000);//10000 十秒
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- rowStyle:function(row,index){
- var style = {};
- if(row.warning){
- style={css:{'color':'#ff0000'}};
- }
- return style;
- }
- }
- };
- return Controller;
- });
|