商丘12345 前端

newRepositoryAdd.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. var ids=helper.request.queryString("ids");
  2. var depId=helper.request.queryString("depId");
  3. //编辑器配置
  4. KindEditor.ready(function(K) {
  5. window.baseon = K.create('#baseon', {
  6. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  7. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  8. allowFileManager: true
  9. }); //添加弹出框编辑器
  10. });
  11. KindEditor.ready(function(K) {
  12. window.process = K.create('#process', {
  13. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  14. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  15. allowFileManager: true
  16. }); //添加弹出框编辑器
  17. });
  18. KindEditor.ready(function(K) {
  19. window.material = K.create('#material', {
  20. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  21. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  22. allowFileManager: true
  23. }); //添加弹出框编辑器
  24. });
  25. KindEditor.ready(function(K) {
  26. window.template = K.create('#template', {
  27. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  28. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  29. allowFileManager: true
  30. }); //添加弹出框编辑器
  31. });
  32. KindEditor.ready(function(K) {
  33. window.payinfo = K.create('#payinfo', {
  34. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  35. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  36. allowFileManager: true
  37. }); //添加弹出框编辑器
  38. });
  39. $(document).ready(function() {
  40. if(depId==111){
  41. $('.radio-inline input').attr('checked','false');
  42. $('.radio-inline input:first').attr('checked','true');
  43. }
  44. $('.tab_list li').click(function() {
  45. var index = $(this).index();
  46. $(this).addClass('active').siblings().removeClass('active');
  47. $('.tab_content>div').eq(index).show().siblings().hide();
  48. })
  49. $('.save').click(function(){
  50. saveCon();
  51. })
  52. //上传附件
  53. $("#scwj").click(function() {
  54. $("#upFile").trigger("click");
  55. })
  56. $("#upFile").change(function() {
  57. upload();
  58. })
  59. //保存
  60. function saveCon(){
  61. var paymoney=$('#paymoney').val()*1;
  62. var a=paymoney.toFixed(2)
  63. // var reg=/^([+-]?)\d*\.?\d+$/;
  64. // if($("#publicphone1").val()!==''){
  65. // if(!reg.test($.trim($("#publicphone1").val()))) {
  66. // layer.confirm('请输入有效的公开电话!', {
  67. // btn: ['确定'] //按钮
  68. // });
  69. // $("#publicphone1").val('');
  70. // $("#publicphone1").focus();
  71. // return;
  72. // }
  73. // }if($("#publicphone2").val()!==''){
  74. // if(!reg.test($.trim($("#publicphone2").val()))){
  75. // layer.confirm('请输入有效的公开电话!', {
  76. // btn: ['确定'] //按钮
  77. // });
  78. // $("#publicphone2").val('');
  79. // $("#publicphone2").focus();
  80. // return;
  81. // }
  82. // }if($("#privatephone1").val()!==''){
  83. // if(!reg.test($.trim($("#privatephone1").val()))){
  84. // layer.confirm('请输入有效的内部电话!', {
  85. // btn: ['确定'] //按钮
  86. // });
  87. // $("#privatephone1").val('');
  88. // $("#privatephone1").focus();
  89. // return;
  90. // }
  91. // }if($("#privatephone2").val()!==''){
  92. // if(!reg.test($.trim($("#privatephone2").val()))){
  93. // layer.confirm('请输入有效的内部电话!', {
  94. // btn: ['确定'] //按钮
  95. // });
  96. // $("#privatephone2").val('');
  97. // $("#privatephone2").focus();
  98. // return;
  99. // }
  100. // }if($("#otherpublicphone").val()!==''){
  101. // if(!reg.test($.trim($("#otherpublicphone").val()))){
  102. // layer.confirm('请输入有效的协办单位公开电话!', {
  103. // btn: ['确定'] //按钮
  104. // });
  105. // $("#otherpublicphone").val('');
  106. // $("#otherpublicphone").focus();
  107. // return;
  108. // }
  109. // }if($("#otherprivatephone").val()!==''){
  110. // if(!reg.test($.trim($("#otherprivatephone").val()))){
  111. // layer.confirm('请输入有效的协办单位内部电话!', {
  112. // btn: ['确定'] //按钮
  113. // });
  114. // $("#otherprivatephone").val('');
  115. // $("#otherprivatephone").focus();
  116. // return;
  117. // }
  118. // }
  119. $.ajax({
  120. type:'post',
  121. url:huayi.config.callcenter_url +'Repository/SaveRepository',
  122. async:true,
  123. dataType:'json',
  124. data:{
  125. token:$.cookie("token"),
  126. deptid:depId,//单位id
  127. id:ids,//知识库id
  128. key:$('#key').val(),//关键字
  129. title:$('#title').val(),//事件名称
  130. maindept:$('#maindept').val(),//主办单位
  131. publicphone1:$('#publicphone1').val(),//公开电话1
  132. publicphone2:$('#publicphone2').val(),//公开电话2
  133. privatephone1:$('#privatephone1').val(),//内部电话1
  134. privatephone2:$('#privatephone2').val(),//内部电话2
  135. points:$('#points').val(),//询问要点
  136. baseanswer:$('#baseanswer').val(),//标准话术
  137. endanswer:$('#endanswer').val(),//结案参考
  138. dealtype:$('#dealtype').val(),//办理方式
  139. legallimittime:$('#legallimittime').val(),//法定办结时限
  140. promiselimittime:$('#promiselimittime').val(),//承诺办结时限
  141. ispay: $('input[name="ispay"]:checked ').val(),//是否收费
  142. issubmit: $('input[name="isAudit"]:checked ').val(),//是否审核
  143. isurgent: $('input[name="isUrgency"]:checked ').val(),//是否紧急事项
  144. paymoney: a,//收费标准
  145. officeaddress: $('#officeaddress').val(),//办公地点
  146. serobject: $('#serobject').val(),//办理对象
  147. busline: $('#busline').val(),//乘车路线
  148. officetime: $('#officetime').val(),//办公时间
  149. otherdept: $('#otherdept').val(),// 协办单位
  150. otherpublicphone: $('#otherpublicphone').val(),// 协办单位公开电话
  151. otherprivatephone: $('#otherprivatephone').val(),//协办单位内部电话
  152. remark: $('#remark').val(),//备注
  153. baseon: encodeURIComponent(baseon.html()),//设定依据
  154. process: encodeURIComponent(process.html()),//办理流程
  155. material: encodeURIComponent(material.html()),//办理材料
  156. template: encodeURIComponent(template.html()),//办理结果样本
  157. payinfo: encodeURIComponent(payinfo.html()),//收费标准及依据
  158. files: $('#file').val() //收费标准及依据
  159. },
  160. success:function(data){
  161. if(data.state.toLowerCase()=='success'){
  162. debugger
  163. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  164. parent.layer.close(index); //再执行关闭
  165. parent.layer.msg(data.message); //再执行关闭
  166. parent.$('#table1').bootstrapTable('refresh'); //再执行关闭
  167. }
  168. }
  169. });
  170. }
  171. //获取知识库详情
  172. if(ids){
  173. $.ajax({
  174. type:"get",
  175. url:huayi.config.callcenter_url +"Repository/GetRepository",
  176. async:true,
  177. dataType:'json',
  178. data:{
  179. token: $.cookie("token"),
  180. id:ids
  181. },
  182. success:function(result){
  183. if(result.state.toLowerCase()=='success'){
  184. var con=result.data.data;
  185. $('#key').val(con.F_Key);//关键字
  186. $('#title').val(con.F_Title);//事件名称
  187. $('#maindept').val(con.F_MainDept);//主办单位
  188. $('#publicphone1').val(con.F_PublicPhone1);//公开电话1
  189. $('#publicphone2').val(con.F_PublicPhone2);//公开电话2
  190. $('#privatephone1').val(con.F_PrivatePhone1);//内部电话1
  191. $('#privatephone2').val(con.F_PrivatePhone2);//内部电话2
  192. $('#points').val(con.F_Points);//询问要点
  193. $('#baseanswer').val(con.F_BaseAnswer);//标准话术
  194. $('#endanswer').val(con.F_EndAnswer);//结案参考
  195. $('#dealtype').val(con.F_DealType);//办理方式
  196. $('#legallimittime').val(con.F_LegalLimitTime);//法定办结时限
  197. $('#promiselimittime').val(con.F_PromiseLimitTime);//承诺办结时限
  198. // $('input[name="ispay"]:checked ').val(F_PayMoney);//是否收费
  199. $('input[name="ispay"][value="'+con.F_IsPay+'"]').prop("checked","checked"),//是否收费
  200. $('input[name="isUrgency"][value="'+con.F_IsPay+'"]').prop("checked","checked"),//是否紧急事项
  201. $('#paymoney').val(con.F_PayMoney);//收费标准
  202. $('#officeaddress').val(con.F_OfficeAddress);//办公地点
  203. $('#serobject').val(con.F_Object);//办理对象
  204. $('#busline').val(con.F_BusLine);//乘车路线
  205. $('#officetime').val(con.F_OfficeTime);//办公时间
  206. $('#otherdept').val(con.F_OtherDept);// 协办单位
  207. $('#otherpublicphone').val(con.F_OtherPublicPhone);// 协办单位公开电话
  208. $('#otherprivatephone').val(con.F_OtherPrivatePhone);//协办单位内部电话
  209. $('#remark').val(con.F_Remark);//备注
  210. baseon.html(con.F_BaseOn);
  211. process.html(con.F_Process);
  212. material.html(con.F_Material);
  213. template.html(con.F_Template);
  214. payinfo.html(con.F_PayInfo);
  215. depId=con.F_DeptId;
  216. $(result.data.file).each(function(k,q){
  217. var strs='<span class="files" fiel-num="'+ q.F_FileId +'">'+ q.F_FileName.substring(19) +'<i class="fa fa-remove del_file"></i></span>'
  218. $(strs).appendTo($('.fileBox')).find('.del_file').click(function(event){
  219. event.stopPropagation();
  220. $(this).parent().remove();
  221. file_num()
  222. console.log($('.fileBox').find('.del_file'))
  223. })
  224. file_num()
  225. })
  226. }
  227. }
  228. });
  229. }
  230. })
  231. //上传文件
  232. function upload() {
  233. var Files = document.getElementById("upFile").files;
  234. if(Files.length > 0) {
  235. var formData = new FormData();
  236. for(var i = 0; i < Files.length; i++) {
  237. formData.append('file' + i, Files[i]);;
  238. }
  239. console.log(formData)
  240. formData.append("token", $.cookie("token"));
  241. var typeName=Files[0].name.split('.')[1];
  242. if (typeName=="png"||typeName=='jpg'||typeName=='mp4'||typeName=='mp3'||typeName=='pdf'||typeName=='doc'||typeName=='docx'||typeName=='xls'||typeName=='xlsx') {
  243. $.ajax({
  244. url: huayi.config.callcenter_url + "/WorkOrder/UploadFile",
  245. type: "POST",
  246. data: formData,
  247. /**
  248. *必须false才会自动加上正确的Content-Type
  249. */
  250. contentType: false,
  251. /**
  252. * 必须false才会避开jQuery对 formdata 的默认处理
  253. * XMLHttpRequest会对 formdata 进行正确的处理
  254. */
  255. processData: false,
  256. success: function(result) {
  257. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  258. $("#upFile").change(function() {
  259. upload();
  260. });
  261. var r = $.parseJSON(result);
  262. if(r.state.toLowerCase() == "success") {
  263. // $(".fjnr").text(r.data[0].F_FileName);
  264. var a = r.data;
  265. $(a).each(function(i, n) {
  266. var strs = '<span class="files" fiel-num="' + n.F_FileId + '">' + n.F_FileName.substring(19) + '<i class="fa fa-remove del_file"></i></span>'
  267. $(strs).appendTo($('.fileBox')).find('.del_file').click(function(event) {
  268. event.stopPropagation();
  269. $(this).parent().remove();
  270. file_num()
  271. })
  272. })
  273. file_num()
  274. }
  275. }
  276. });
  277. }else{
  278. layer.msg("格式不正确");
  279. }
  280. } else {
  281. layer.confirm('请上传文件!', {
  282. btn: ['确定']
  283. });
  284. }
  285. }
  286. //上传文件隐藏域值
  287. function file_num() {
  288. var str = '';
  289. var Str;
  290. $('.fileBox .files').each(function(j, m) {
  291. var aa = $(m).attr("fiel-num")
  292. console.log(aa);
  293. str += aa + ",";
  294. Str = (str.substring(str.length - 1) == ',') ? str.substring(0, str.length - 1) : str;
  295. })
  296. $("#file").val(Str);
  297. }