虞城12345_前端

newRepositoryAdd.js 12KB

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