1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- var detailtbl, datas;
- layui.use(['form', 'table'], function () {
- var form = layui.form;
- console.log(window.location.href);
- var table = layui.table;
- var id = QueryString('id');
- if (id == null || id == undefined || id == '') {
- id = '0';
- }
- if (id != '0') {
- $.ajax({
- url: '/mes/api/tprocess/' + id,
- type: 'get',
- dataType: 'json',
- success: function (res) {
- form.val('addForm', {
- FCode: res.fCode,
- FName: res.fName,
- Remark: res.remark
- });
- }
- });
- }
- form.on('submit(*)', function (data) {
- var obj = {
- ID: id,
- FCode: data.field.FCode,
- FName: data.field.FName,
- Remark: data.field.Remark
- };
- $.ajax({
- url: '/mes/api/tprocess/add',
- contentType: 'application/json',
- type: 'post',
- dataType: 'text',
- data: JSON.stringify(obj),
- success: function (res) {
- var result = res == '0' ? '失败' : '成功';
- var content = id == '0' ? '添加' : '修改';
- var iconId = res == '0' ? 2 : 1;
- var animateId = res == '0' ? 6 : 0;
- id = res;
- if (res != '0') {
- layer.msg(content + result, {
- icon: iconId,
- anim: animateId
- });
- $.ajax({
- url: '/mes/api/tprocess/' + res,
- type: 'get',
- dataType: 'json',
- success: function (res) {
- form.val('addForm', {
- FCode: res.fCode,
- FName: res.fName,
- Remark: res.remark
- });
- }
- });
- parent.reloadTable();
- } else {
- layer.msg('网络错误,请联系管理员', {
- icon: 2,
- animateId: 6
- })
- }
- }
- });
- return false;
- });
- $('#btnAddContinue').click(function () {
- id = '0';
- });
- });
|