商丘12345 前端

newRepositoryAdd.js 12KB

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