商丘12345 前端

newRepositoryAdd.js 12KB

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