虞城12345_前端

newRepositoryAdd.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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/AddRepository',
  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. paymoney: a,//收费标准
  139. officeaddress: $('#officeaddress').val(),//办公地点
  140. serobject: $('#serobject').val(),//办理对象
  141. busline: $('#busline').val(),//乘车路线
  142. officetime: $('#officetime').val(),//办公时间
  143. otherdept: $('#otherdept').val(),// 协办单位
  144. otherpublicphone: $('#otherpublicphone').val(),// 协办单位公开电话
  145. otherprivatephone: $('#otherprivatephone').val(),//协办单位内部电话
  146. remark: $('#remark').val(),//备注
  147. baseon: encodeURIComponent(baseon.html()),//设定依据
  148. process: encodeURIComponent(process.html()),//办理流程
  149. material: encodeURIComponent(material.html()),//办理材料
  150. template: encodeURIComponent(template.html()),//办理结果样本
  151. payinfo: encodeURIComponent(payinfo.html()),//收费标准及依据
  152. files: $('#file').val() //收费标准及依据
  153. },
  154. success:function(data){
  155. if(data.state.toLowerCase()=='success'){
  156. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  157. parent.layer.close(index); //再执行关闭
  158. parent.layer.msg(data.message); //再执行关闭
  159. parent.$('#table1').bootstrapTable('refresh'); //再执行关闭
  160. }
  161. }
  162. });
  163. }
  164. //获取知识库详情
  165. if(ids){
  166. $.ajax({
  167. type:"get",
  168. url:huayi.config.callcenter_url +"Repository/GetRepository",
  169. async:true,
  170. dataType:'json',
  171. data:{
  172. token: $.cookie("token"),
  173. id:ids
  174. },
  175. success:function(result){
  176. if(result.state.toLowerCase()=='success'){
  177. var con=result.data.data;
  178. $('#key').val(con.F_Key);//关键字
  179. $('#title').val(con.F_Title);//事件名称
  180. $('#maindept').val(con.F_MainDept);//主办单位
  181. $('#publicphone1').val(con.F_PublicPhone1);//公开电话1
  182. $('#publicphone2').val(con.F_PublicPhone2);//公开电话2
  183. $('#privatephone1').val(con.F_PrivatePhone1);//内部电话1
  184. $('#privatephone2').val(con.F_PrivatePhone2);//内部电话2
  185. $('#points').val(con.F_Points);//询问要点
  186. $('#baseanswer').val(con.F_BaseAnswer);//标准话术
  187. $('#endanswer').val(con.F_EndAnswer);//结案参考
  188. $('#dealtype').val(con.F_DealType);//办理方式
  189. $('#legallimittime').val(con.F_LegalLimitTime);//法定办结时限
  190. $('#promiselimittime').val(con.F_PromiseLimitTime);//承诺办结时限
  191. // $('input[name="ispay"]:checked ').val(F_PayMoney);//是否收费
  192. $('input[name="ispay"][value="'+con.F_IsPay+'"]').prop("checked","checked");//是否收费
  193. $('#paymoney').val(con.F_PayMoney);//收费标准
  194. $('#officeaddress').val(con.F_OfficeAddress);//办公地点
  195. $('#serobject').val(con.F_Object);//办理对象
  196. $('#busline').val(con.F_BusLine);//乘车路线
  197. $('#officetime').val(con.F_OfficeTime);//办公时间
  198. $('#otherdept').val(con.F_OtherDept);// 协办单位
  199. $('#otherpublicphone').val(con.F_OtherPublicPhone);// 协办单位公开电话
  200. $('#otherprivatephone').val(con.F_OtherPrivatePhone);//协办单位内部电话
  201. $('#remark').val(con.F_Remark);//备注
  202. baseon.html(con.F_BaseOn);
  203. process.html(con.F_Process);
  204. material.html(con.F_Material);
  205. template.html(con.F_Template);
  206. payinfo.html(con.F_PayInfo);
  207. depId=con.F_DeptId;
  208. // $('#baseon').val(con.F_BaseOn);//设定依据
  209. // $('#process').val(con.F_Process);//办理流程
  210. // $('#material').val(con.F_Material);//办理材料
  211. // $('#template').val(con.F_Template);//办理结果样本
  212. // $('#payinfo').val(con.F_PayInfo);//收费标准及依据
  213. // $('#files').val() //收费标准及依据
  214. $(result.data.file).each(function(k,q){
  215. var strs='<span class="files" fiel-num="'+ q.F_FileId +'">'+ q.F_FileName.substring(19) +'<i class="fa fa-remove del_file"></i></span>'
  216. $(strs).appendTo($('.fileBox')).find('.del_file').click(function(event){
  217. event.stopPropagation();
  218. $(this).parent().remove();
  219. file_num()
  220. console.log($('.fileBox').find('.del_file'))
  221. })
  222. file_num()
  223. })
  224. }
  225. }
  226. });
  227. }
  228. })
  229. //上传文件
  230. function upload() {
  231. var Files = document.getElementById("upFile").files;
  232. if(Files.length > 0) {
  233. var formData = new FormData();
  234. for(var i = 0; i < Files.length; i++) {
  235. formData.append('file' + i, Files[i]);;
  236. }
  237. console.log(formData)
  238. formData.append("token", $.cookie("token"));
  239. $.ajax({
  240. url: huayi.config.callcenter_url + "/WorkOrder/UploadFile",
  241. type: "POST",
  242. data: formData,
  243. /**
  244. *必须false才会自动加上正确的Content-Type
  245. */
  246. contentType: false,
  247. /**
  248. * 必须false才会避开jQuery对 formdata 的默认处理
  249. * XMLHttpRequest会对 formdata 进行正确的处理
  250. */
  251. processData: false,
  252. success: function(result) {
  253. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  254. $("#upFile").change(function() {
  255. upload();
  256. });
  257. var r = $.parseJSON(result);
  258. if(r.state.toLowerCase() == "success") {
  259. // $(".fjnr").text(r.data[0].F_FileName);
  260. var a = r.data;
  261. $(a).each(function(i, n) {
  262. var strs = '<span class="files" fiel-num="' + n.F_FileId + '">' + n.F_FileName.substring(19) + '<i class="fa fa-remove del_file"></i></span>'
  263. $(strs).appendTo($('.fileBox')).find('.del_file').click(function(event) {
  264. event.stopPropagation();
  265. $(this).parent().remove();
  266. file_num()
  267. })
  268. })
  269. file_num()
  270. }
  271. }
  272. });
  273. } else {
  274. layer.confirm('请上传文件!', {
  275. btn: ['确定']
  276. });
  277. }
  278. }
  279. //上传文件隐藏域值
  280. function file_num() {
  281. var str = '';
  282. var Str;
  283. $('.fileBox .files').each(function(j, m) {
  284. var aa = $(m).attr("fiel-num")
  285. console.log(aa);
  286. str += aa + ",";
  287. Str = (str.substring(str.length - 1) == ',') ? str.substring(0, str.length - 1) : str;
  288. })
  289. $("#file").val(Str);
  290. }