12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- layui.use(['form', 'table','layer'], function () {
- var form = layui.form;
- detailtbl = layui.table;
- var layer = layui.layer;
- console.log(window.location.href);
- var id = QueryString('id');
- if (id == null || id == undefined || id == '') {
- id = '0';
- }
- if (id != '0') {
- $.ajax({
- url: '/mes/api/mesexception/getsingle?exId=' + id,
- type: 'get',
- dataType: 'json',
- success: function (res) {
- form.val('addForm', {
- MacCode: res.macCode,
- ExcCode: res.excCode,
- Remark: res.remark
- });
- }
- });
- }
- form.on('submit(*)', function (data) {
- var obj = {
- id: id,
- macCode: data.field.MacCode,
- excCode: data.field.ExcCode,
- remark: data.field.Remark,
- isUpdate: false,
- reccode: getCookieValue('userid')
- };
- if (id == '0') {
- for (var j = 0; j < parent.datas.length; j++) {
- if (parent.datas[j].macCode == obj.macCode && parent.datas[j].excCode == obj.excCode) {
- layer.msg('该明细已存在,不能重复添加!', {
- icon: 2,
- anim: 6
- });
- return;
- }
- }
- parent.datas.push(obj);
-
- } else {
- for (var i = 0; i < parent.datas.length; i++) {
- if (parent.datas[i].ID == id) {
- parent.datas[i].MacCode = obj.MacCode;
- parent.datas[i].ExcCode = obj.ExcCode;
- parent.datas[i].Remark = obj.Remark;
- parent.datas[i].IsUpdate = true;
- break;
- }
- }
- }
- console.log(']]]]]]]]]]]]]]]]]');
- console.log(parent.datas);
- parent.refreshTable();
- return false;
- });
- });
|