Bez popisu

addOrEditZhiShiKuGuide.js 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. if(dtkey && dtkey.length>0){
  119. $("#reflectCategory").val(dtkey[0].name);
  120. $("#keyId").val(dtkey[0].id);
  121. }
  122. $(dtfile).each(function (k, q) {
  123. var strs =
  124. '<span class="files" fiel-num="' +
  125. q.F_FileId +
  126. '">' +
  127. q.F_FileName.substring(19) +
  128. '<i class="fa fa-remove del_file"></i></span>';
  129. $(strs)
  130. .appendTo($(".fileBox"))
  131. .find(".del_file")
  132. .click(function (event) {
  133. event.stopPropagation();
  134. $(this).parent().remove();
  135. file_num();
  136. console.log($(".fileBox").find(".del_file"));
  137. });
  138. file_num();
  139. });
  140. }
  141. },
  142. });
  143. } else {
  144. $(".addOrEditDisplay").hide();
  145. }
  146. });
  147. //上传文件
  148. function upload() {
  149. var Files = document.getElementById("upFile").files;
  150. if (Files.length > 0) {
  151. var formData = new FormData();
  152. for (var i = 0; i < Files.length; i++) {
  153. formData.append("file" + i, Files[i]);
  154. }
  155. formData.append("token", $.cookie("token"));
  156. console.log(formData);
  157. console.log("123",formData.file0);
  158. var typeName = Files[0].name.split(".")[1];
  159. if (
  160. typeName == "png" ||
  161. typeName == "jpg" ||
  162. typeName == "mp4" ||
  163. typeName == "mp3" ||
  164. typeName == "pdf" ||
  165. typeName == "doc" ||
  166. typeName == "docx" ||
  167. typeName == "xls" ||
  168. typeName == "xlsx"
  169. ) {
  170. $.ajax({
  171. url: huayi.config.callcenter_url + "LawGuide/UploadFile",
  172. type: "POST",
  173. data: formData,
  174. /**
  175. *必须false才会自动加上正确的Content-Type
  176. */
  177. contentType: false,
  178. /**
  179. * 必须false才会避开jQuery对 formdata 的默认处理
  180. * XMLHttpRequest会对 formdata 进行正确的处理
  181. */
  182. processData: false,
  183. success: function (result) {
  184. document.getElementById("upFile").outerHTML =
  185. document.getElementById("upFile").outerHTML;
  186. $("#upFile").change(function () {
  187. upload();
  188. });
  189. var r = $.parseJSON(result);
  190. if (r.state.toLowerCase() == "success") {
  191. // $(".fjnr").text(r.data[0].F_FileName);
  192. var a = r.data;
  193. $(a).each(function (i, n) {
  194. var strs =
  195. '<span class="files" fiel-num="' +
  196. n.F_FileId +
  197. '">' +
  198. n.F_FileName.substring(19) +
  199. '<i class="fa fa-remove del_file"></i></span>';
  200. $(strs)
  201. .appendTo($(".fileBox"))
  202. .find(".del_file")
  203. .click(function (event) {
  204. event.stopPropagation();
  205. $(this).parent().remove();
  206. file_num();
  207. });
  208. });
  209. file_num();
  210. }
  211. },
  212. });
  213. } else {
  214. layer.msg("格式不正确");
  215. }
  216. } else {
  217. layer.confirm("请上传文件!", {
  218. btn: ["确定"],
  219. });
  220. }
  221. }
  222. //上传文件隐藏域值
  223. function file_num() {
  224. var str = "";
  225. var Str;
  226. $(".fileBox .files").each(function (j, m) {
  227. var aa = $(m).attr("fiel-num");
  228. console.log(aa);
  229. str += aa + ",";
  230. Str =
  231. str.substring(str.length - 1) == ","
  232. ? str.substring(0, str.length - 1)
  233. : str;
  234. });
  235. $("#file").val(Str);
  236. }