Nessuna descrizione

addOrEditZhiShiKuGuide.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. var id = helper.request.queryString("id");
  2. $(document).ready(function () {
  3. laydate.skin('blue');
  4. laydate({
  5. elem: '#publishTime',
  6. event: 'focus',
  7. istime: true,
  8. format: 'YYYY-MM-DD hh:mm:ss'
  9. });
  10. laydate({
  11. elem: '#effectiveTime',
  12. event: 'focus',
  13. istime: true,
  14. format: 'YYYY-MM-DD hh:mm:ss'
  15. });
  16. laydate({
  17. elem: '#invalidTime',
  18. event: 'focus',
  19. istime: true,
  20. format: 'YYYY-MM-DD hh:mm:ss'
  21. });
  22. laydate({
  23. elem: '#processingTime',
  24. event: 'focus',
  25. istime: true,
  26. format: 'YYYY-MM-DD hh:mm:ss'
  27. });
  28. $(".save").click(function () {
  29. saveCon();
  30. });
  31. //上传附件
  32. $("#scwj").click(function () {
  33. $("#upFile").trigger("click");
  34. });
  35. $("#upFile").change(function () {
  36. upload();
  37. });
  38. //保存
  39. function saveCon() {
  40. $.ajax({
  41. type: "post",
  42. url: huayi.config.callcenter_url + "LawGuide/AddModel",
  43. async: true,
  44. dataType: "json",
  45. data: {
  46. token: $.cookie("token"),
  47. id: id, //知识库id
  48. key: $("#keyId").val(), // 关键词id
  49. fabudanwei: $("#publishUnit").val(), // 发布单位
  50. faburen: $("#publishPersonal").val(), // 发布人
  51. hangye: $("#industry").val(), // 所属行业
  52. diqu: $("#address").val(), // 地区
  53. fabushijian: $("#publishTime").val(), // 发布时间
  54. shengxiaoshijian: $("#effectiveTime").val(), // 生效时间
  55. shixiaoshijian: $("#invalidTime").val(), // 失效时间
  56. yewumingcheng: $("#businessName").val(), // 业务名称
  57. biaoshibianma: $("#identifyEncoding").val(), // 标识编码
  58. shenqingtiaojian: $("#applicationConditions").val(), // 申请条件
  59. zhengceyiju: $("#policyBased").val(), // 政策依据
  60. wangshangbanlilianjie: $("#onlineURL").val(), // 网上办理链接
  61. file: $("#file").val(), // 附件
  62. banlicailiao: $("#handlingMaterials").val(), // 办理材料
  63. banlishixian: $("#processingTimeLimit").val(), // 办理时限
  64. banlididian: $("#handlingPlace").val(), // 办理地点
  65. banlishijian: $("#processingTime").val(), // 办理时间
  66. banlidianhua: $("#telephone").val(), // 电话
  67. qitashuoming: $("#otherInstructions").val(), // 其他说明
  68. banliliucheng: $("#process").val(), // 办理流程
  69. beizhu: $("#remark").val(), // 备注
  70. },
  71. success: function (data) {
  72. if (data.state.toLowerCase() == "success") {
  73. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  74. parent.layer.close(index); //再执行关闭
  75. parent.layer.msg(data.message); //再执行关闭
  76. parent.$("#tableList").bootstrapTable("refresh"); //再执行关闭
  77. }
  78. },
  79. });
  80. }
  81. //获取知识库详情
  82. if (id) {
  83. $(".addOrEditDisplay").show();
  84. $.ajax({
  85. type: "get",
  86. url: huayi.config.callcenter_url + "LawGuide/GetModel",
  87. async: true,
  88. dataType: "json",
  89. data: {
  90. token: $.cookie("token"),
  91. id: id,
  92. },
  93. success: function (result) {
  94. if (result.state.toLowerCase() == "success") {
  95. var model = result.data.model;
  96. var dtkey = result.data.dtkey;
  97. var dtfile = result.data.dtfile;
  98. $("#publishUnit").val(model.F_FaBuDanWei);
  99. $("#publishPersonal").val(model.F_FaBuRen);
  100. $("#industry").val(model.F_HangYe);
  101. $("#address").val(model.F_DiQu);
  102. $("#publishTime").val(model.F_FaBuShiJian);
  103. $("#effectiveTime").val(model.F_ShengXiaoShiJian);
  104. $("#invalidTime").val(model.F_ShiXiaoShiJian);
  105. $("#businessName").val(model.F_YeWuMingCheng);
  106. $("#identifyEncoding").val(model.F_BiaoShiBianMa);
  107. $("#applicationConditions").val(model.F_ShenQingTiaoJian);
  108. $("#policyBased").val(model.F_ZhengCeYiJu);
  109. $("#onlineURL").val(model.F_WangShangBanLiLianJie);
  110. $("#handlingMaterials").val(model.F_BanLiCaiLiao);
  111. $("#processingTimeLimit").val(model.F_BanLiShiXian);
  112. $("#handlingPlace").val(model.F_BanLiDiDian);
  113. $("#processingTime").val(model.F_BanLiShiJian);
  114. $("#telephone").val(model.F_BanLiDianHua);
  115. $("#otherInstructions").val(model.F_QiTaShuoMing);
  116. $("#process").val(model.F_BanLiLiuCheng);
  117. $("#remark").val(model.F_BeiZhu);
  118. $("#reflectCategory").val(dtkey[0].name);
  119. $("#keyId").val(dtkey[0].id);
  120. $(dtfile).each(function (k, q) {
  121. var strs =
  122. '<span class="files" fiel-num="' +
  123. q.F_FileId +
  124. '">' +
  125. q.F_FileName.substring(19) +
  126. '<i class="fa fa-remove del_file"></i></span>';
  127. $(strs)
  128. .appendTo($(".fileBox"))
  129. .find(".del_file")
  130. .click(function (event) {
  131. event.stopPropagation();
  132. $(this).parent().remove();
  133. file_num();
  134. console.log($(".fileBox").find(".del_file"));
  135. });
  136. file_num();
  137. });
  138. }
  139. },
  140. });
  141. } else {
  142. $(".addOrEditDisplay").hide();
  143. }
  144. });
  145. //上传文件
  146. function upload() {
  147. var Files = document.getElementById("upFile").files;
  148. if (Files.length > 0) {
  149. var formData = new FormData();
  150. for (var i = 0; i < Files.length; i++) {
  151. formData.append("file" + i, Files[i]);
  152. }
  153. formData.append("token", $.cookie("token"));
  154. console.log(formData);
  155. console.log("123",formData.file0);
  156. var typeName = Files[0].name.split(".")[1];
  157. if (
  158. typeName == "png" ||
  159. typeName == "jpg" ||
  160. typeName == "mp4" ||
  161. typeName == "mp3" ||
  162. typeName == "pdf" ||
  163. typeName == "doc" ||
  164. typeName == "docx" ||
  165. typeName == "xls" ||
  166. typeName == "xlsx"
  167. ) {
  168. $.ajax({
  169. url: huayi.config.callcenter_url + "LawGuide/UploadFile",
  170. type: "POST",
  171. data: formData,
  172. /**
  173. *必须false才会自动加上正确的Content-Type
  174. */
  175. contentType: false,
  176. /**
  177. * 必须false才会避开jQuery对 formdata 的默认处理
  178. * XMLHttpRequest会对 formdata 进行正确的处理
  179. */
  180. processData: false,
  181. success: function (result) {
  182. document.getElementById("upFile").outerHTML =
  183. document.getElementById("upFile").outerHTML;
  184. $("#upFile").change(function () {
  185. upload();
  186. });
  187. var r = $.parseJSON(result);
  188. if (r.state.toLowerCase() == "success") {
  189. // $(".fjnr").text(r.data[0].F_FileName);
  190. var a = r.data;
  191. $(a).each(function (i, n) {
  192. var strs =
  193. '<span class="files" fiel-num="' +
  194. n.F_FileId +
  195. '">' +
  196. n.F_FileName.substring(19) +
  197. '<i class="fa fa-remove del_file"></i></span>';
  198. $(strs)
  199. .appendTo($(".fileBox"))
  200. .find(".del_file")
  201. .click(function (event) {
  202. event.stopPropagation();
  203. $(this).parent().remove();
  204. file_num();
  205. });
  206. });
  207. file_num();
  208. }
  209. },
  210. });
  211. } else {
  212. layer.msg("格式不正确");
  213. }
  214. } else {
  215. layer.confirm("请上传文件!", {
  216. btn: ["确定"],
  217. });
  218. }
  219. }
  220. //上传文件隐藏域值
  221. function file_num() {
  222. var str = "";
  223. var Str;
  224. $(".fileBox .files").each(function (j, m) {
  225. var aa = $(m).attr("fiel-num");
  226. console.log(aa);
  227. str += aa + ",";
  228. Str =
  229. str.substring(str.length - 1) == ","
  230. ? str.substring(0, str.length - 1)
  231. : str;
  232. });
  233. $("#file").val(Str);
  234. }