暫無描述

WorkOrderEnd.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /**
  2. * 工单处理(结束)
  3. * */
  4. $(document).ready(function() {
  5. autosize($('textarea'));
  6. var ID = helper.request.queryString("oid"); //工单ID
  7. if(ID) {
  8. getWorkOrderInfo(ID);
  9. }
  10. //点击确定
  11. $("#clgd").click(function() {
  12. if(!$("#cont").val()) {
  13. layer.confirm('请输入处理内容!', {
  14. icon: 2,
  15. btn: ['确定']
  16. });
  17. return;
  18. }
  19. dealWorkOrder(ID);
  20. });
  21. })
  22. $('#Depth').find('input[type="radio"]').on('change', function() {
  23. if($(this).val() == "0") { //业务办理
  24. $('#F_Address,#F_Address').show();
  25. }else{
  26. $('#F_Address,#F_Address').hide();
  27. }
  28. });
  29. //获取工单信息
  30. function getWorkOrderInfo(oid) {
  31. $.ajax({
  32. type: "get",
  33. url: huayi.config.callcenter_url + "WorkOrderNew/GetDetails",
  34. async: true,
  35. dataType: 'json',
  36. data: {
  37. id: oid,
  38. token: $.cookie("token")
  39. },
  40. success: function(data) {
  41. /*验证请求*/
  42. if(data.state == "success") {
  43. var Str = data.rows;
  44. if(Str && Str.length > 0) {
  45. $('#cl_gdbh').text(Str[0].F_WorkOrderCode); //工单编号
  46. $("#cl_gdlx").text(Str[0].F_TypeName); //工单类型
  47. $("#xq_source").text(Str[0].F_SourceName); //工单来源
  48. // $("#xq_handle").text(Str[0].YWLXName); //业务办理
  49. $("#cl_khxm").text(Str[0].F_CusName); //姓名
  50. $("#cl_khdh").text(helper.filter.cutTel(Str[0].F_CusPhone)); //电话
  51. $("#cl_gdn").text(Str[0].F_DeptName); //部门
  52. $('#cl_gdnr').text(decodeURIComponent(Str[0].Detail));
  53. if($("#cl_gdlx").text()=="抽检"){
  54. if($("#cl_gdn").text()=="市场管理科"){
  55. $("#abcde").show();
  56. $("#abc").hide();
  57. }
  58. }else if($("#cl_gdlx").text()=="投诉"){
  59. if($("#cl_gdn").text()=="市场管理科"){
  60. $("#abc").show();
  61. $("#abcde").hide();
  62. }
  63. }else if($("#cl_gdlx").text()=="咨询"){
  64. if($("#cl_gdn").text()=="市场管理科"){
  65. $("#ccc").show();
  66. $("#ddd").hide();
  67. }
  68. }
  69. if($("#cl_gdlx").text()=="抽检"){
  70. if($("#cl_gdn").text()=="质量管理部"){
  71. $("#abcdef").show();
  72. $("#abcde").hide();
  73. $("#shicon").hide();
  74. }
  75. }else if($("#cl_gdlx").text()=="投诉"){
  76. if($("#cl_gdn").text()=="质量管理部"){
  77. $("#abcd").show();
  78. $("#abc").hide();
  79. $("#shicon").show();
  80. }
  81. }else if($("#cl_gdlx").text()=="咨询"){
  82. if($("#cl_gdn").text()=="质量管理部"){
  83. $("#ddd").show();
  84. $("#ccc").hide();
  85. $("#shicon").show();
  86. }
  87. }
  88. //微信内文件(暂时不用)
  89. var Files = Str[0].Files;
  90. if(Files) {
  91. var a;
  92. var b;
  93. $(Files).each(function(i, n) {
  94. a = n.F_FileType.split("\/")[0];
  95. b = n.F_FileName.split(".")[1];
  96. // console.log(a);
  97. if(a == 'image') {
  98. $('<div class="img-box"><a href="+' + n.F_FileUrl + '" download="' + n.F_FileName + '"><img src="' + n.F_FileUrl + '" alt="" class="image-item" data-preview-group="1" /><span class="">' + b + '</span></a><div>').appendTo(".space");
  99. } else {
  100. $('<div class="img-box "><a href="+' + n.F_FileUrl + '" download="' + n.F_FileName + '"><span class="">' + b + '</span></a><div>').appendTo(".space");
  101. }
  102. })
  103. }
  104. }
  105. }
  106. }
  107. });
  108. }
  109. $(function(){
  110. $("#duoxuan").on("click",function(){
  111. var ichk=$("input:checkbox:checked").map(function(){
  112. return $(this).val();
  113. }).get().join(",");
  114. $("#txtServerType").val(ichk);
  115. // alert($("#txtServerType").val())
  116. })
  117. })
  118. $('#yijian').find('input[type="radio"]').on('change', function() {
  119. if($(this).val() == "不同意") { //业务办理
  120. $('#nrr,#ytt').show();
  121. }else{
  122. $('#nrr,#ytt').hide();
  123. }
  124. });
  125. $('#buchang').find('input[type="radio"]').on('change', function() {
  126. if($(this).val() == "钱款") { //业务办理
  127. $('#mction,#mcttic').show();
  128. }else{
  129. $('#mction,#mcttic').hide();
  130. }
  131. });
  132. //获取工单类型
  133. function getTypeName(val) {
  134. var str = '';
  135. switch(val + '') {
  136. case '107':
  137. str = "咨询";
  138. break;
  139. case '108':
  140. str = "投诉";
  141. break;
  142. }
  143. return str;
  144. }
  145. //处理
  146. function dealWorkOrder(oid) {
  147. var isDetail = helper.request.queryString("isDetail"); //是否是详情页面的处理
  148. $.post(huayi.config.callcenter_url + 'WorkOrderNew/DealWorkOrder', {
  149. orderid: oid, //否 strubg 工单ID
  150. isover: $("input[name='isoverOptions']:checked").val(), //是否完结 0否,1是
  151. cont: $("#cont").val(), //否 处理内容
  152. ProductBase: $("#zhibao").val(),
  153. // dealType:$("input[name='istions']:checked").val(),
  154. // isvisit: $("#huifangisvisit").val(),
  155. QualityEventLevel: $("#cat").val(),
  156. shenpi:$("#shenpi").val(),
  157. ClaimAmount:$("#cataa").val(),
  158. ResponsibleUnit: $("#txtServerType").val(),
  159. ApprovalOpinions: $("input[name='tong']:checked").val(),
  160. ApprovalDisagree: $("#butong").val(),
  161. CompensationMethod:$("input[name='buchan']:checked").val(),
  162. CompensationMoney: $("#bcqkun").val(),
  163. CResponsibleUnits: $("#danwei").val(),
  164. Fquantity: $("#shuliang").val(),
  165. ImprovementRequirements: $("#yaoqiu").val(),
  166. CApprovalNo: $("#danhao").val(),
  167. ProductBase: $("#chou").val(),
  168. uncont: $("#wclyy").val(),//未处理原因
  169. isvisit: $("#huifang").find('input[type="radio"]:checked').val(),
  170. IsRecord: $("#gongzuol").find('input[type="radio"]:checked').val(),
  171. // QualityMonth:
  172. F_Files: proimglist && proimglist.join(','),
  173. token: $.cookie("token")
  174. }, function(result) {
  175. result = $.parseJSON(result);
  176. if(result.state.toLowerCase() == "success") {
  177. if(isDetail === "true") {
  178. parent.parent.layer.closeAll();
  179. parent.parent.$('#orderlist').bootstrapTable('refresh');
  180. parent.parent.layer.msg("工单结单成功!");
  181. } else {
  182. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  183. parent.layer.close(index); //再执行关闭
  184. parent.$('#workorderlist').bootstrapTable('refresh');
  185. parent.$('.Closed').trigger('click');
  186. parent.layer.msg("工单结单成功!");
  187. }
  188. top.workcount();
  189. }
  190. })
  191. }
  192. // $('#gdxq_').find('input[type="radio"]').on('change', function() {
  193. // if($(this).val() == "0") { //业务办理
  194. // $('#wclyy').show();
  195. // }else{
  196. // $('#wclyy').hide();
  197. // }
  198. // });
  199. $("#gdxq_").click(function(){
  200. $("#F_Address").show();
  201. });
  202. $(document).ready(function () {
  203. var wid = helper.request.queryString("wid");
  204. // CPZL($("#zhibao"));//产品种类
  205. SCSCJD($("#zhibao"));//初审意见
  206. ZLSJDJ($("#cat"));//质量事件等级
  207. ZLSJDJ($("#dengji"));//质量事件等级
  208. ZLZRDW($("#cataa"));//责任单位
  209. ZLZRDW($("#danwei"));//责任单位
  210. SCSCJD($("#chou"));//责任单位SCSCJD
  211. WCLYY($("#wclyy"));//责任单位SCSCJD
  212. SCCS($("#chushen"));//初审意见
  213. });
  214. function WCLYY(obj) {
  215. obj.empty();
  216. obj.append('<option selected="selected" value="">请选择</option>');
  217. $.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
  218. "token": $.cookie("token"),
  219. flag:"WCLYY",
  220. }, function (data) {
  221. if (data.state.toLowerCase() == "success") {
  222. var content = data.data;
  223. $(content).each(function (i, n) {
  224. $("<option value='" + n.F_Name + "'>" + n.F_Name + "</option>").appendTo(obj);
  225. })
  226. }
  227. })
  228. }
  229. function SCSCJD(obj) {
  230. obj.empty();
  231. obj.append('<option selected="selected" value="">请选择</option>');
  232. $.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
  233. "token": $.cookie("token"),
  234. flag:"SCSCJD",
  235. }, function (data) {
  236. if (data.state.toLowerCase() == "success") {
  237. var content = data.data;
  238. $(content).each(function (i, n) {
  239. $("<option value='" + n.F_Name + "'>" + n.F_Name + "</option>").appendTo(obj);
  240. })
  241. }
  242. })
  243. }
  244. function SCCS(obj) {
  245. obj.empty();
  246. obj.append('<option selected="selected" value="">请选择</option>');
  247. $.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
  248. "token": $.cookie("token"),
  249. flag:"SCCS",
  250. }, function (data) {
  251. if (data.state.toLowerCase() == "success") {
  252. var content = data.data;
  253. $(content).each(function (i, n) {
  254. $("<option value='" + n.F_Name + "'>" + n.F_Name + "</option>").appendTo(obj);
  255. })
  256. }
  257. })
  258. }
  259. function ZLZRDW(obj) {
  260. obj.empty();
  261. obj.append('<option selected="selected" value="">请选择</option>');
  262. $.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
  263. "token": $.cookie("token"),
  264. flag:"ZLZRDW",
  265. }, function (data) {
  266. if (data.state.toLowerCase() == "success") {
  267. var content = data.data;
  268. $(content).each(function (i, n) {
  269. $("<option value='" + n.F_Name + "'>" + n.F_Name + "</option>").appendTo(obj);
  270. })
  271. }
  272. })
  273. }
  274. function ZLSJDJ(obj) {
  275. obj.empty();
  276. obj.append('<option selected="selected" value="">请选择</option>');
  277. $.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
  278. "token": $.cookie("token"),
  279. flag:"ZLSJDJ",
  280. }, function (data) {
  281. if (data.state.toLowerCase() == "success") {
  282. var content = data.data;
  283. $(content).each(function (i, n) {
  284. $("<option value='" + n.F_Name + "'>" + n.F_Name + "</option>").appendTo(obj);
  285. })
  286. }
  287. })
  288. }
  289. /**
  290. * 附件上传直接在知识库管理拿来用 开始
  291. * */
  292. var proimglist = []; //保存附件数组
  293. var uploader; //上传实例
  294. var limitNum = 6; //限制数量
  295. var edit_id = helper.request.queryString("edit_id");
  296. var token = $.cookie("token");
  297. $(function() {
  298. autosize($('textarea'));
  299. getChangeTree();
  300. if(edit_id) {
  301. getDetail();
  302. } else {
  303. $('#kn_type').val('顶级分类');
  304. $('#kn_type').attr('data-id', 0)
  305. uploaderImages();
  306. }
  307. //初始化 下拉
  308. $('.inps1').focus(function() {
  309. $('.xlAdd').css('display', 'block');
  310. });
  311. $('.xl_one').click(function() {
  312. if($('.xlAdd').css('display') == 'block') {
  313. $('.xlAdd').css('display', 'none')
  314. } else {
  315. $('.xlAdd').css('display', 'block')
  316. }
  317. });
  318. $('.addTree').mouseleave(function() {
  319. $(this).css('display', 'none')
  320. });
  321. $('#save_knowledge').on('click', saveKnowledge);
  322. });
  323. //修改弹出框内 下拉树形图参数配置项
  324. function getChangeTree() {
  325. var setting3 = {
  326. data: {
  327. key: {
  328. name: "text"
  329. },
  330. simpleData: {
  331. enable: true,
  332. idKey: "id",
  333. rootPId: 0
  334. }
  335. },
  336. callback: {
  337. onClick: changeTreeClick
  338. }
  339. }
  340. $.get(huayi.config.callcenter_url + 'KnowledgeClass/GetList', {
  341. // "pid": pid,
  342. "token": token,
  343. }, function(result) {
  344. result = $.parseJSON(result);
  345. $.fn.zTree.init($("#addTreeDemo"), setting3, result.data); //实例化树形图
  346. });
  347. }
  348. function changeTreeClick(event, treeId, treeNode) {
  349. $('#kn_type').val(treeNode.text);
  350. $('#kn_type').attr('data-id', treeNode.id);
  351. };
  352. //获取详情
  353. function getDetail() {
  354. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  355. $.ajax({
  356. type: "post",
  357. url: huayi.config.callcenter_url + "Knowledge/GetInfo",
  358. async: true,
  359. dataType: 'json',
  360. data: {
  361. infoid: edit_id,
  362. token: token
  363. },
  364. success: function(data) {
  365. var con = data.data;
  366. $('#kn_title').val(con.F_Title);
  367. $('#kn_key').val(con.F_KeyWords);
  368. $('#kn_content').val(con.F_Description);
  369. $('#kn_type').val(con.F_Expand1);
  370. $('#kn_type').attr('data-id', con.F_CategoryId);
  371. //附件
  372. var proimglists = con.FileUrls;
  373. proimglists = proimglists == null ? [] : proimglists;
  374. limitNum -= proimglists.length;
  375. uploaderImages(); //附件上传
  376. if(proimglists.length > 0) {
  377. $('#fileNum').text(proimglists.length);
  378. var $list = $("#fileList");
  379. $.each(proimglists, function(i, v) {
  380. proimglist.push(v.F_FileId);
  381. if(v.F_FileType.split("\/")[0] === 'image') {
  382. //原来的图片
  383. var $li = $(
  384. '<li><span class="img_mask"><i class="img_del"></i></span>' +
  385. '<img src="' + v.F_FileUrl + '" title="原来的图片"/>' +
  386. '<span class="file_name">' + v.F_FileName + '</span>' +
  387. '</li>'
  388. );
  389. $list.append($li);
  390. } else {
  391. var $liFile = $(
  392. '<li><span class="img_mask"><i class="img_del"></i></span>' +
  393. '<div class="noThumb" title="原来的文件"><i class="glyphicon glyphicon-paperclip"></i><p>无法预览</p></div>' +
  394. '<span class="file_name">' + v.F_FileName + '</span>' +
  395. '</li>'
  396. );
  397. $list.append($liFile);
  398. }
  399. });
  400. $list.find('li').off('click');
  401. $list.find('li').on('click', '.img_del', function() {
  402. $(this).parent().parent().remove();
  403. var itemFileName = $(this).parent().parent().find('.file_name').text();
  404. $.each(proimglists, function(i, v) {
  405. if(v && v.F_FileName == itemFileName) {
  406. proimglist.splice(i, 1);
  407. }
  408. });
  409. $('#fileNum').text(proimglist.length);
  410. limitNum = 6 - proimglist.length;
  411. uploaderImages();
  412. });
  413. }
  414. dtd.resolve(); // 改变Deferred对象的执行状态
  415. }
  416. });
  417. return dtd.promise(); // 返回promise对象
  418. }
  419. //保存
  420. function saveKnowledge() {
  421. var wUrl;
  422. if(!$.trim($('#kn_type').val())) {
  423. layer.confirm('所属分类不能为空', {
  424. icon: 2,
  425. btn: ['确定'] //按钮
  426. });
  427. return;
  428. }
  429. if(!$.trim($('#kn_title').val())) {
  430. layer.confirm('标题不能为空', {
  431. icon: 2,
  432. btn: ['确定'] //按钮
  433. });
  434. return;
  435. }
  436. if(edit_id) {
  437. wURL = "Knowledge/EditInfo";
  438. } else {
  439. wURL = "Knowledge/AddInfo";
  440. }
  441. $.ajax({
  442. type: "post",
  443. url: huayi.config.callcenter_url + wURL,
  444. dataType: 'json',
  445. async: true,
  446. beforeSend: function() { //触发ajax请求开始时执行
  447. $('#save_knowledge').attr("disabled", true);
  448. $('#save_knowledge').text('保存中...');
  449. $(document).off('click', '#save_knowledge', saveKnowledge);
  450. loadIndex = layer.load();
  451. },
  452. data: {
  453. infoid: edit_id,
  454. title: $('#kn_title').val(),
  455. key: $('#kn_key').val(),
  456. con: helper.filter.delHtmlTag($('#kn_content').val()),
  457. pid: $('#kn_type').attr('data-id'),
  458. fileids: proimglist && proimglist.join(','),
  459. token: token
  460. },
  461. success: function(result) {
  462. if(result.state.toLowerCase() === "success") {
  463. var index = parent.layer.getFrameIndex(window.name);
  464. parent.layer.close(index);
  465. parent.table.bootstrapTable('refresh');
  466. layer.msg("保存成功");
  467. }
  468. },
  469. error: function(textStatus) {
  470. layer.close(loadIndex);
  471. layer.confirm('网络繁忙,请稍后再试...', {
  472. icon: 7,
  473. closeBtn: 0,
  474. btn: ['确定'] //按钮
  475. });
  476. $('#save_knowledge').text('保存');
  477. $('#save_knowledge').attr("disabled", false);
  478. $(document).off('click', '#save_knowledge', saveKnowledge);
  479. $(document).on('click', '#save_knowledge', saveKnowledge);
  480. },
  481. complete: function(XMLHttpRequest, textStatus) {
  482. layer.close(loadIndex);
  483. if(textStatus == 'timeout') {
  484. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  485. xmlhttp.abort();
  486. layer.confirm('网络超时,请稍后再试...', {
  487. icon: 7,
  488. closeBtn: 0,
  489. btn: ['确定'] //按钮
  490. });    
  491. }
  492. $('#save_knowledge').text('保存');
  493. $('#save_knowledge').attr("disabled", false);
  494. $(document).off('click', '#save_knowledge', saveKnowledge);
  495. $(document).on('click', '#save_knowledge', saveKnowledge);
  496. },
  497. });
  498. }
  499. //上传附件
  500. function uploaderImages() {
  501. if(uploader) {
  502. uploader.destroy();
  503. }
  504. uploader = WebUploader.create({
  505. auto: true, // 选完文件后,是否自动上传
  506. swf: '../../js/webuploader/Uploader.swf', // swf文件路径
  507. server: huayi.config.callcenter_url + "Knowledge/UpLoadProcess", // 文件接收服务端
  508. pick: '#imgPicker', // 选择文件的按钮。可选
  509. formData: {
  510. token: token
  511. },
  512. // 多类型文件上传
  513. accept: {
  514. title: 'Files',
  515. extensions: 'gif,jpg,jpeg,bmp,png,pdf,doc,docx,txt,xls,xlsx,ppt,pptx,zip,mp3,mp4,text,csv',
  516. mimeTypes: 'image/*,text/*,audio/mpeg,audio/mp4, video/mp4'
  517. //word
  518. +',application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document'
  519. //excel
  520. +',application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  521. //ppt
  522. +',application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation'
  523. +',application/pdf'
  524. +',application/zip'
  525. +',application/csv'
  526. // title: 'Images',
  527. // extensions: 'gif,jpg,jpeg,bmp,png',
  528. // mimeTypes: 'image/*'
  529. },
  530. compress: false, //webuploader默认压缩图片,设置compress:false,可以按照原始比例上传图片
  531. //fileVal: "upFile",//设置文件上传域的name。
  532. threads: limitNum, //上传并发数。允许同时最大上传进程数,为了保证文件上传顺序
  533. fileNumLimit: limitNum,
  534. fileSizeLimit: 180 * 1024 * 1024, // 180 M
  535. fileSingleSizeLimit: 30 * 1024 * 1024 // 30 M
  536. });
  537. uploader.on('fileQueued', function(file) {
  538. var $list = $("#fileList"),
  539. $li = $(
  540. '<li id="' + file.id + '"><span class="img_mask"><i class="img_del"></i></span>' +
  541. '<img/>' +
  542. '<span class="img_state"><i></i></span>' +
  543. '<span class="file_name">' + file.name + '</span>' +
  544. '</li>'
  545. ),
  546. $img = $li.find('img');
  547. // $list为容器jQuery实例
  548. $list.append($li);
  549. // 保存缩略图
  550. uploader.makeThumb(file, function(error, src) {
  551. if(error) {
  552. $img.replaceWith('<div class="noThumb"><i class="glyphicon glyphicon-paperclip"></i><p>无法预览</p></div>');
  553. return;
  554. }
  555. $img.attr('src', src);
  556. }, 109, 109); //109*109为缩略图尺寸
  557. //绑定删除
  558. $('#' + file.id).on('click', '.img_del', function() {
  559. uploader.removeFile(file);
  560. var $fileLi = $('#' + file.id);
  561. $fileLi.off().find('.img_del').off().end().remove();
  562. var itemFileName = $(this).parent().parent().find('.file_name').text();
  563. $.each(proimglist, function(i, v) {
  564. if(v && v.filename == itemFileName) {
  565. proimglist.splice(i, 1);
  566. //helper.methods.delImgs(v.filesmallurl, v.fileurl);
  567. }
  568. });
  569. $('#fileNum').text(proimglist.length);
  570. });
  571. });
  572. // 文件上传过程中保存进度条实时显示。
  573. uploader.on('uploadProgress', function(file, percentage) {
  574. var $li = $('#' + file.id),
  575. $percent = $li.find('.progress span');
  576. // 避免重复保存
  577. if(!$percent.length) {
  578. $percent = $('<div class="progress" style="">' +
  579. '<span class="text">0%</span>' +
  580. '<span class="percentage"></span>' +
  581. '</div>')
  582. .appendTo($li)
  583. .find('span');
  584. }
  585. $percent.eq(0).text(Math.round(percentage * 100) + '%');
  586. $percent.eq(1).css('width', Math.round(percentage * 100) + '%');
  587. });
  588. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  589. uploader.on('uploadSuccess', function(file, res) {
  590. proimglist.push(res.data.F_FileId);
  591. $('#fileNum').text(proimglist.length);
  592. $('#' + file.id).addClass('upload-state-done');
  593. });
  594. // 文件上传失败,显示上传出错。
  595. uploader.on('uploadError', function(file) {
  596. var $li = $('#' + file.id),
  597. $error = $li.find('div.error');
  598. // 避免重复创建
  599. if(!$error.length) {
  600. $error = $('<div class="error"></div>').appendTo($li);
  601. }
  602. $error.text('上传失败');
  603. });
  604. // 完成上传完了,成功或者失败,先删除进度条。
  605. uploader.on('uploadComplete', function(file) {
  606. $('#' + file.id).find('.progress').remove();
  607. });
  608. uploader.onError = function(code) {
  609. // console.log('Error:' + code);
  610. switch(code) {
  611. case "Q_EXCEED_NUM_LIMIT":
  612. layer.msg('只能上传六个文件。');
  613. break;
  614. case "Q_TYPE_DENIED":
  615. layer.msg('文件类型不正确。');
  616. break;
  617. case "F_DUPLICATE":
  618. layer.msg('该文件已上传,请选择其它文件。');
  619. break;
  620. case "F_EXCEED_SIZE":
  621. layer.msg('单文件大小不能超过30M。');
  622. break;
  623. case "Q_EXCEED_SIZE_LIMIT":
  624. layer.msg('总文件大小不能超过180M。');
  625. break;
  626. default:
  627. break;
  628. }
  629. };
  630. }
  631. /**
  632. * 附件上传直接在知识库管理拿来用 结束
  633. * */