Aucune description

addOrEditZhiShiKuGlossary.js 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. $(".save").click(function () {
  23. saveCon();
  24. });
  25. //上传附件
  26. $("#scwj").click(function () {
  27. $("#upFile").trigger("click");
  28. });
  29. $("#upFile").change(function () {
  30. upload();
  31. });
  32. //保存
  33. function saveCon() {
  34. $.ajax({
  35. type: "post",
  36. url: huayi.config.callcenter_url + "NounInterpretation/AddModel",
  37. async: true,
  38. dataType: "json",
  39. data: {
  40. token: $.cookie("token"),
  41. id: id, //知识库id
  42. key: $("#keyId").val(), // 关键词id
  43. fabudanwei: $("#publishUnit").val(), // 发布单位
  44. faburen: $("#publishPersonal").val(), // 发布人
  45. hangye: $("#industry").val(), // 所属行业
  46. diqu: $("#address").val(), // 地区
  47. fabushijian: $("#publishTime").val(), // 发布时间
  48. shengxiaoshijian: $("#effectiveTime").val(), // 生效时间
  49. shixiaoshijian: $("#invalidTime").val(), // 失效时间
  50. fawenwenhao: $("#documentNumber").val(), // 发文文号
  51. fawendanwei: $("#documentUnit").val(), // 发文单位
  52. biaoshibianma: $("#identifyEncoding").val(), // 标识编码
  53. file: $("#file").val(), // 附件
  54. zhengcemingci: $("#policyName").val(), // 政策名称
  55. jiedadanwei: $("#answeringUnit").val(), // 解答单位
  56. redianwenti: $("#hotIssues").val(), // 热点问题/名词解释
  57. wentijieda: $("#contentAnswer").val(), // 内容解答
  58. },
  59. success: function (data) {
  60. if (data.state.toLowerCase() == "success") {
  61. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  62. parent.layer.close(index); //再执行关闭
  63. parent.layer.msg(data.message); //再执行关闭
  64. parent.$("#tableList").bootstrapTable("refresh"); //再执行关闭
  65. }
  66. },
  67. });
  68. }
  69. //获取知识库详情
  70. if (id) {
  71. $(".addOrEditDisplay").show();
  72. $.ajax({
  73. type: "get",
  74. url: huayi.config.callcenter_url + "NounInterpretation/GetModel",
  75. async: true,
  76. dataType: "json",
  77. data: {
  78. token: $.cookie("token"),
  79. id: id,
  80. },
  81. success: function (result) {
  82. if (result.state.toLowerCase() == "success") {
  83. var model = result.data.model;
  84. var dtkey = result.data.dtkey;
  85. var dtfile = result.data.dtfile;
  86. $("#publishUnit").val(model.F_FaBuDanWei);
  87. $("#publishPersonal").val(model.F_FaBuRen);
  88. $("#industry").val(model.F_HangYe);
  89. $("#address").val(model.F_DiQu);
  90. $("#publishTime").val(model.F_FaBuShiJian);
  91. $("#effectiveTime").val(model.F_ShengXiaoShiJian);
  92. $("#invalidTime").val(model.F_ShiXiaoShiJian);
  93. $("#documentNumber").val(model.F_FaWenWenHao);
  94. $("#documentUnit").val(model.F_FaWenDanWei);
  95. $("#identifyEncoding").val(model.F_BiaoShiBianMa);
  96. $("#policyName").val(model.F_ZhengCeMingCi);
  97. $("#answeringUnit").val(model.F_JieDaDanWei);
  98. $("#hotIssues").val(model.F_ReDianWenTi);
  99. $("#contentAnswer").val(model.F_WenTiJieDa);
  100. $("#reflectCategory").val(dtkey[0].name);
  101. $("#keyId").val(dtkey[0].id);
  102. $(dtfile).each(function (k, q) {
  103. var strs =
  104. '<span class="files" fiel-num="' +
  105. q.F_FileId +
  106. '">' +
  107. q.F_FileName.substring(19) +
  108. '<i class="fa fa-remove del_file"></i></span>';
  109. $(strs)
  110. .appendTo($(".fileBox"))
  111. .find(".del_file")
  112. .click(function (event) {
  113. event.stopPropagation();
  114. $(this).parent().remove();
  115. file_num();
  116. console.log($(".fileBox").find(".del_file"));
  117. });
  118. file_num();
  119. });
  120. }
  121. },
  122. });
  123. } else {
  124. $(".addOrEditDisplay").hide();
  125. }
  126. });
  127. //上传文件
  128. function upload() {
  129. var Files = document.getElementById("upFile").files;
  130. if (Files.length > 0) {
  131. var formData = new FormData();
  132. for (var i = 0; i < Files.length; i++) {
  133. formData.append("file" + i, Files[i]);
  134. }
  135. formData.append("token", $.cookie("token"));
  136. console.log(formData);
  137. console.log("123",formData.file0);
  138. var typeName = Files[0].name.split(".")[1];
  139. if (
  140. typeName == "png" ||
  141. typeName == "jpg" ||
  142. typeName == "mp4" ||
  143. typeName == "mp3" ||
  144. typeName == "pdf" ||
  145. typeName == "doc" ||
  146. typeName == "docx" ||
  147. typeName == "xls" ||
  148. typeName == "xlsx"
  149. ) {
  150. $.ajax({
  151. url: huayi.config.callcenter_url + "NounInterpretation/UploadFile",
  152. type: "POST",
  153. data: formData,
  154. /**
  155. *必须false才会自动加上正确的Content-Type
  156. */
  157. contentType: false,
  158. /**
  159. * 必须false才会避开jQuery对 formdata 的默认处理
  160. * XMLHttpRequest会对 formdata 进行正确的处理
  161. */
  162. processData: false,
  163. success: function (result) {
  164. document.getElementById("upFile").outerHTML =
  165. document.getElementById("upFile").outerHTML;
  166. $("#upFile").change(function () {
  167. upload();
  168. });
  169. var r = $.parseJSON(result);
  170. if (r.state.toLowerCase() == "success") {
  171. // $(".fjnr").text(r.data[0].F_FileName);
  172. var a = r.data;
  173. $(a).each(function (i, n) {
  174. var strs =
  175. '<span class="files" fiel-num="' +
  176. n.F_FileId +
  177. '">' +
  178. n.F_FileName.substring(19) +
  179. '<i class="fa fa-remove del_file"></i></span>';
  180. $(strs)
  181. .appendTo($(".fileBox"))
  182. .find(".del_file")
  183. .click(function (event) {
  184. event.stopPropagation();
  185. $(this).parent().remove();
  186. file_num();
  187. });
  188. });
  189. file_num();
  190. }
  191. },
  192. });
  193. } else {
  194. layer.msg("格式不正确");
  195. }
  196. } else {
  197. layer.confirm("请上传文件!", {
  198. btn: ["确定"],
  199. });
  200. }
  201. }
  202. //上传文件隐藏域值
  203. function file_num() {
  204. var str = "";
  205. var Str;
  206. $(".fileBox .files").each(function (j, m) {
  207. var aa = $(m).attr("fiel-num");
  208. console.log(aa);
  209. str += aa + ",";
  210. Str =
  211. str.substring(str.length - 1) == ","
  212. ? str.substring(0, str.length - 1)
  213. : str;
  214. });
  215. $("#file").val(Str);
  216. }