12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- layui.use('form', function () {
- var form = layui.form;
- var id = QueryString('id');
- if (id == null || id == undefined || id == '') {
- id = '0';
- }
- if (id !== '0') {
- $.ajax({
- url: '/mes/api/staff/' + id,
- type: 'get',
- dataType: 'json',
- success: function (res) {
- form.val('addForm', {
- FCode: res.fCode,
- FName: res.fName,
- FStatusName: res.fStatusName,
- 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/staff/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 != null && res != '0') {
- layer.msg(content + result, {
- icon: iconId,
- anim: animateId
- });
- $.ajax({
- url: '/mes/api/staff/' + res,
- type: 'get',
- dataType: 'json',
- success: function (res) {
- form.val('addForm', {
- FCode: res.fCode,
- FName: res.fName,
- FStatusName: res.fStatusName,
- Remark: res.remark
- });
- parent.reloadTable();
- }
- });
- } else {
- layer.msg('网络错误,请联系管理员', {
- icon: 2,
- animateId: 6
- })
- }
- }
- });
- return false;
- });
- $('#btnAddContinue').click(function () {
- id = '0';
- });
- });
|