123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- var layer, eTbl;
- layui.use(['table', 'layer', 'laydate'], function () {
- var table = layui.table;
- var orderId = QueryString('orderId');
- if (orderId != null && orderId != '' && orderId != undefined) {
- where = {
- poCode: orderId
- }
- }
- layer = layui.layer;
- var laydate = layui.laydate;
- laydate.render({
- elem: '#starttime'
- });
- laydate.render({
- elem: '#endtime'
- });
- var where;
- //第一个实例
- eTbl = table.render({
- elem: '#tbl',
- url: '/mes/api/lotmst/get', //数据接口
- page: true, //开启分页
- toolbar: '#toolbar',
- where: where,
- cols: [[ //表头
- { checkbox: true },
- { field: 'lotNo', title: 'LOTNo', width: 160, sort: true },
- { field: 'poCode', title: '生产订单编号', width: 120, sort: true },
- {
- field: 'fCount', title: '数量', width: 160, sort: true, templet: function (d) {
- var count = d.fCount;
- var formatCount = '';
- while (count >= 1000) {
- formatCount = ',' + count.toString().substr(count.toString().length - 3, 3) + formatCount;
- count = parseInt(count.toString().substr(0, count.toString().length - 3));
- }
- formatCount = count + formatCount;
- return formatCount;
- }
- },
- { field: 'fStatus', title: '状态', width: 160, sort: true },
- { field: 'enterName', title: '录入人', width: 160 },
- {
- field: 'rectime', title: '录入日期', width: 240, sort: true, templet: function (d) {
- return (d.rectime == null || d.rectime == undefined) ? '' : timeFormat(d.rectime);
- }
- },
- { field: 'remark', title: '备注', width: 380 }
- ]],
- done: function () {
- $('[name=pocode]').val(orderId);
- $.ajaxSettings.async = false;
- }
- });
- table.on('toolbar(macmodel)', function (obj) {
- if (obj.event == 'search') {
- showToast();
- var startTime, endTime, poCode, lotNo;
- poCode = $('[name=pocode]').val();
- lotNo = $('[name=lotno]').val();
- var withtime = $('#withTime').prop('checked');
- var s = $('#starttime').val();
- var e = $('#endtime').val();
- if (withtime) {
- startTime = s;
- endTime = e;
- }
- where = {
- poCode: poCode,
- lotNo: lotNo,
- startTime: startTime,
- endTime: endTime
- };
- eTbl.reload({
- where: where,
- page: {
- curr: 1
- },
- done: function () {
-
- $('[name=pocode]').val(poCode);
- $('[name=lotno]').val(lotNo);
- laydate.render({
- elem: '#starttime',
- value: s
- });
- laydate.render({
- elem: '#endtime',
- value: e
- });
- if (withtime) {
- $('#withTime').attr('checked', withtime);
- $('#withTime').next().addClass('layui-form-checked');
- }
- layer.closeAll('loading');
- }
- });
- } else if (obj.event == 'all') {
- showToast();
- $('[name=pocode]').val('');
- $('[name=lotno]').val('');
- eTbl.reload({
- where: {
- poCode: '',
- lotNo: '',
- startTime: '',
- endTime: ''
- },
- page: {
- curr: 1
- },
- done: function () {
- laydate.render({
- elem: '#starttime'
- });
- laydate.render({
- elem: '#endtime'
- });
- $('#withTime').attr('checked', false);
- $('#withTime').next().removeClass('layui-form-checked');
- layer.closeAll('loading');
- }
- });
- }
- });
- //table.on('toolbar(macmodel)', function (obj) {
- // if (obj.event == 'add') {
- // layer.open({
- // type: 2,
- // title: '新增机器型号',
- // content: 'macmodelAdd.html',
- // area: ['800px', '400px']
- // });
- // } else if (obj.event == 'delete') {
- // var checkStatus = table.checkStatus('tbl');
- // console.log(checkStatus);
- // if (checkStatus.data.length === 0) {
- // layer.msg('请先选中需要操作的型号!', {
- // icon: 2,
- // anim: 6
- // });
- // return;
- // }
- // var ids = '';
- // for (var i = 0; i < checkStatus.data.length; i++) {
- // ids += checkStatus.data[i].id + ',';
- // }
- // ids = ids.substr(0, ids.length - 1);
- // $.ajax({
- // url: '/mes/api/macmodel/delete',
- // type: 'post',
- // contentType: 'application/json',
- // dataType: 'text',
- // data: JSON.stringify(ids),
- // success: function (res) {
- // if (res) {
- // layer.msg('操作成功', {
- // icon: 1,
- // anim: 0
- // });
- // eTbl.reload(true);
- // } else {
- // layer.msg('操作失败', {
- // icon: 2,
- // anim: 6
- // });
- // }
- // }
- // });
- // }
- //});
- //table.on('rowDouble(macmodel)', function (obj) {
- // console.log(obj);
- // layer.open({
- // type: 2,
- // content: 'macmodelAdd.html?id=' + obj.data.id,
- // area: ['800px', '400px']
- // });
- //});
- table.on('sort(macmodel)', function (obj) {
- where['sort'] = obj.field;
- where['order'] = obj.type;
- eTbl.reload({
- initSort: obj,
- where: where
- })
- });
- });
- function reloadTable() {
- eTbl.reload();
- }
|