郑许地铁

LostGoodsRegist.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. 
  2. layui.use(['form', 'upload', 'layer', 'jquery', 'laydate'], function () {
  3. var form = layui.form,
  4. layer = parent.layer === undefined ? layui.layer : parent.layer,
  5. $ = layui.jquery,
  6. laydate = layui.laydate, upload = layui.upload;
  7. //日期
  8. laydate.render({
  9. elem: '#date'
  10. , type: 'datetime'
  11. });
  12. //绑定原始文件域
  13. upload.render({
  14. elem: '#test10'
  15. , url: '/LostGoods/UploadFile/'
  16. , done: function (res) {
  17. //如果上传失败
  18. if (res.code > 0) {
  19. return layer.msg(res.msg);
  20. } else {
  21. console.log(res.src)
  22. $("#imgShow").attr('src', res.src);
  23. $("#F_GoodsImg").val(res.src);
  24. $(".mengban").css('z-index', '-1');
  25. }
  26. //上传成功
  27. }
  28. });
  29. //监听提交
  30. form.on('submit(SubmitData)', function (data) {
  31. //所有表单数据
  32. var dataArr = new Array();
  33. dataArr = data.field;
  34. //属性
  35. if (dataArr["F_PropertyId"] != null && dataArr["F_PropertyId"] != "") {
  36. dataArr["F_PropertyName"] = $("#F_PropertyId").find("option:selected").text();
  37. }
  38. //种类
  39. if (dataArr["F_KindsId"] != null && dataArr["F_KindsId"] != "") {
  40. dataArr["F_KindsName"] = $("#F_KindsId").find("option:selected").text();
  41. }
  42. $.ajax({
  43. url: "/LostGoods/SaveRegistInfo",
  44. type: "post",
  45. async: false,//同步请求
  46. contentType: "application/json",
  47. dataType: "text",
  48. cache: false,
  49. data: JSON.stringify(dataArr),
  50. // data: dataArr,
  51. success: function (thisResult, result) {
  52. if (thisResult == "True") {
  53. layer.open({
  54. content: '保存成功'
  55. , btn: ['确定']
  56. , yes: function (index, layero) {
  57. layer.close(index);
  58. ////刷新父窗体
  59. var thisindex = parent.layer.getFrameIndex(window.name); //获取窗口索引
  60. parent.layer.close(thisindex);
  61. }
  62. , cancel: function () {
  63. var thisindex = parent.layer.getFrameIndex(window.name); //获取窗口索引
  64. parent.layer.close(thisindex);
  65. }
  66. });
  67. return false;
  68. } else {
  69. layer.open({
  70. title: '提示'
  71. , content: '保存失败!'
  72. });
  73. return false;
  74. }
  75. },
  76. error: function (error) {
  77. return false;
  78. }
  79. });
  80. return false;
  81. });
  82. //.监听当前 select,动态改变子项
  83. form.on('select(fcoptype)', function (d) {
  84. $.ajax({
  85. url: "/CallRecord/GetDeptUsers",
  86. type: "get",
  87. contentType: "application/json",
  88. dataType: "text",
  89. cache: false,
  90. data: { "deptId": d.value },
  91. success: function (result, status) {
  92. if (status) {
  93. $("#F_CREATEBY").empty();
  94. $("#F_CREATEBY").append("<option value='' ></option>");
  95. var list = eval("(" + result + ")");
  96. if (list.length > 0) {
  97. for (var i = 0; i < list.length; i++) {
  98. $("#F_CREATEBY").append("<option value='" + list[i].F_UserId + "'>" + list[i].F_UserName + "</option>");
  99. }
  100. }
  101. form.render('select');
  102. }
  103. else {
  104. layui.layer.alert("获取该部门下用户信息失败!", {
  105. icon: 2
  106. });
  107. }
  108. }
  109. });
  110. });
  111. })
  112. $('.DicSelect').on('click', function () {
  113. layer.open({
  114. type: 2,
  115. scrollbar: false,
  116. content: '/LostGoods/GetPathInfo',
  117. area: ['700px', '500px'],
  118. id: 'GetPathInfo',
  119. title: '选择'
  120. })
  121. });
  122. function saveParams(code1, name1) {
  123. $("#F_PlaceId").val(code1);
  124. $("#F_PlaceName").val(name1);
  125. }
  126. //关闭当前页
  127. $('.closeThisPage').on('click', function () {
  128. var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
  129. parent.layer.close(index);
  130. });