123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- var layer, eTbl, pId, unbindTbl;
- layui.use(['table', 'layer', 'element'], function () {
- var table = layui.table;
- var element = layui.element;
- layer = layui.layer;
- pId = QueryString("pId");
- // document.querySelector('#macprocess').src = 'processwithmac.html?pId=' + pId;
- //第一个实例
- eTbl = table.render({
- elem: '#tbl',
- height: 600,
- url: '/mes/api/machine', //数据接口
- page: true, //开启分页
- toolbar: '#toolbar',
- cols: [[ //表头
- { checkbox: true },
- { field: 'fCode', title: '代码', sort: true },
- { field: 'fName', title: '名称', sort: true },
- {
- field: 'fModel', title: '机型', sort: true, templet: function (d) {
- return d.fModelName;
- }
- },
- { field: 'imsIp', title: 'IMS程序所在电脑IP' },
- {
- field: 'rectime', title: '录入日期', sort: true, templet: function (d) {
- return (d.rectime == null || d.rectime == undefined) ? '' : timeFormat(d.rectime);
- }
- },
- { field: 'remark', title: '备注' }
- ]],
- where: {
- filter: " and a.id not in (select macid from MacTProcess) "
- }
- });
- table.on('toolbar(machine)', function (obj) {
- layer.confirm('您确定要这样做吗?', function (index) {
- 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);
- if (obj.event == 'add') {
- $.ajax({
- url: '/mes/api/tprocess/bindmac',
- type: 'post',
- contentType: 'application/json',
- dataType: 'json',
- data: JSON.stringify({
- pId: pId,
- macIds: ids
- }),
- success: function (res) {
- if (res.code == 1) {
- layer.msg('操作成功', {
- icon: 1,
- anim: 0
- });
- unbindTbl.reload(true);
- eTbl.reload(true);
-
- } else {
- layer.msg(res.message, {
- icon: 2,
- anim: 6
- });
- }
- }
- })
- }
- layer.close(index);
- });
- });
- table.on('rowDouble(machine)', function (obj) {
- console.log(obj);
- layer.open({
- type: 2,
- content: 'machineAdd.html?id=' + obj.data.id,
- area: ['800px', '475px']
- });
- });
- table.on('sort(machine)', function (obj) {
- eTbl.reload({
- initSort: obj,
- where: {
- sort: obj.field,
- order: obj.type
- }
- })
- });
- unbindTbl = table.render({
- elem: '#albindtbl',
- url: '/mes/api/mactprocess', //数据接口
- page: true, //开启分页
- toolbar: '#unbindtoolbar',
- cols: [[ //表头
- { checkbox: true },
- // { type: 'numbers' },
- { field: 'macCode', title: '机台代码', sort: true },
- { field: 'macName', title: '机台名称', sort: true },
- {
- field: 'macModelName', title: '机型', sort: true, templet: function (d) {
- return d.macModelName;
- }
- },
- { field: 'processCode', title: '制程代码', sort: true },
- { field: 'processName', title: '制程名称', sort: true },
- ]],
- where: {
- poCode: pId
- },
- })
- table.on('toolbar(albindmachine)', function (obj) {
- if (obj.event == "delete") {
- layer.confirm('您确定要这样做吗?', function (index) {
- var checkStatus = table.checkStatus('albindtbl');
- 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/mactprocess/delete',
- type: 'post',
- contentType: 'application/json',
- dataType: 'text',
- data: JSON.stringify(ids),
- success: function (res) {
- if (res == '1') {
- layer.msg('操作成功', {
- icon: 1,
- anim: 0
- });
- eTbl.reload(true);
- unbindTbl.reload(true);
- } else {
- layer.msg('操作失败', {
- icon: 2,
- anim: 6
- });
- }
- }
- });
- });
- }
- });
- table.on('sort(albindmachine)', function (obj) {
- eTbl.reload({
- initSort: obj,
- where: {
- poCode: pId,
- sort: obj.field,
- order: obj.type
- }
- })
- });
- });
- function reloadTable() {
- eTbl.reload();
- }
|