No Description

evaluateDeliveryOrder.js 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /**
  2. * 评价配送工单
  3. */
  4. var starNum = 5; //默认是 1 星
  5. var code = helper.request.queryString("code");
  6. var edit_id = helper.request.queryString("edit_id");
  7. var imageArr1 = '';
  8. $(document).ready(function() {
  9. autosize($('textarea'));
  10. $('#woCode').text(code);
  11. uploaderImg(1);
  12. //1 差、2 不满意、3 一般、4 满意、5 很满意
  13. rating.init('#ratingScores', {
  14. mode: 'LightEntire',
  15. num: 5,
  16. readOnly: false,
  17. select: function(num, total) {
  18. var self = this;
  19. layer.tips($(self).attr('title'), '#ratingTips');
  20. // console.log(this);
  21. // $('#ratingTips').text($(this).attr('title'));
  22. // console.log('当前第' + num + '颗,一共' + total + '颗。');
  23. },
  24. chosen: function(num, total) {
  25. //console.log('当前点击的是第' + num + '颗,一共' + total + '颗。');
  26. //rating.init('#rating1','unbindEvent');//只能选择一次
  27. starNum = num;
  28. layer.closeAll();
  29. $('#ratingTips').text($(this).attr('title'));
  30. },
  31. });
  32. $('.greetings_remarks span').click(function() {
  33. $(this).toggleClass('active');
  34. });
  35. $('#save_btns').on('click', btn_save);
  36. });
  37. //评价
  38. function btn_save() {
  39. $.ajax({
  40. type: 'post',
  41. url: huayi.config.callcenter_url + 'distributionapi/api/DistriWorkOrder/evaluate',
  42. dataType: 'json',
  43. async: true,
  44. beforeSend: function() { //触发ajax请求开始时执行
  45. $('#save_btns').attr("disabled", true);
  46. $('#save_btns').text('评价中...');
  47. loadIndex = layer.load();
  48. },
  49. data: {
  50. id: edit_id, //是 string 配送工单id
  51. wocode: code, // 是 string 配送工单code
  52. star: starNum, // 是 int 星级 服务满意度打分☆☆☆☆☆ 注:其中默认都是5星,最低只能打1星,每一星对应20分,合计100分
  53. evaluate: $('#evaluate').val(), // 是 string 评价
  54. label: getExtenArr(), // 是 List<string> 评价标签
  55. files: imageArr1, // 是 List<FileBaseModel> 附件
  56. channel: 1, // 是 int 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信 默认1
  57. },
  58. success: function(data) {
  59. layer.close(loadIndex);
  60. if (data.state === "success") {
  61. var index = parent.layer.getFrameIndex(window.name);
  62. parent.layer.close(index);
  63. parent.$('#table_all').bootstrapTable('refresh');
  64. parent.layer.msg("评价成功");
  65. } else {
  66. $('#save_btns').attr("disabled", false);
  67. $('#save_btns').text('评价');
  68. }
  69. },
  70. error: function(textStatus) {
  71. layer.close(loadIndex);
  72. layer.confirm('网络繁忙,请稍后再试...', {
  73. icon: 7,
  74. closeBtn: 0,
  75. btn: ['确定'] //按钮
  76. });
  77. $('#save_btns').attr("disabled", false);
  78. $('#save_btns').text('评价');
  79. },
  80. complete: function(XMLHttpRequest, textStatus) {
  81. layer.close(loadIndex);
  82. if (textStatus == 'timeout') {
  83. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  84. xmlhttp.abort();
  85. layer.confirm('网络超时,请稍后再试...', {
  86. icon: 7,
  87. closeBtn: 0,
  88. btn: ['确定'] //按钮
  89. });
  90. }
  91. $('#save_btns').attr("disabled", false);
  92. $('#save_btns').text('评价');
  93. },
  94. });
  95. }
  96. //添加图片
  97. function uploaderImg(cindex) {
  98. var imgList = $('#image_list' + cindex),
  99. eleId = $('#filePicker' + cindex),
  100. uploader;
  101. uploader = WebUploader.create({
  102. // 自动上传。
  103. auto: true,
  104. // swf文件路径
  105. swf: '../../../js/Uploader.swf',
  106. // 文件接收服务端。
  107. server: huayi.config.callcenter_url + 'fileserverapi/Api/Upload',
  108. // 选择文件的按钮。可选。
  109. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  110. pick: eleId,
  111. // 图片数量限制
  112. // fileNumLimit: 4,
  113. //可以重复上传
  114. duplicate: true,
  115. formData: {
  116. uploadtype: 'evaluateDeliveryOrder' //自定义文件夹用于存放图片
  117. },
  118. // 只允许选择文件,可选。
  119. accept: {
  120. title: 'Images',
  121. extensions: 'gif,jpg,jpeg,bmp,png',
  122. mimeTypes: 'image/*'
  123. },
  124. fileSizeLimit: 30 * 1024 * 1024, // 30 M
  125. fileSingleSizeLimit: 5 * 1024 * 1024, // 5 M
  126. resize: false
  127. });
  128. //上传图片提示
  129. uploader.on('error', function(handler) {
  130. switch (code) {
  131. case "Q_EXCEED_NUM_LIMIT":
  132. layer.msg('只能上传六个文件。');
  133. break;
  134. case "Q_TYPE_DENIED":
  135. layer.msg('图片类型不正确。');
  136. break;
  137. case "F_DUPLICATE":
  138. layer.msg('该文件已上传,请选择其它文件。');
  139. break;
  140. case "F_EXCEED_SIZE":
  141. layer.msg('单文件大小不能超过5M。');
  142. break;
  143. case "Q_EXCEED_SIZE_LIMIT":
  144. layer.msg('总文件大小不能超过30M。');
  145. break;
  146. default:
  147. break;
  148. }
  149. });
  150. // 当有文件添加进来的时候
  151. uploader.on('fileQueued', function(file) {
  152. var $li = $(
  153. '<div id="' + cindex + '' + file.id + '" class="file-item thumbnail">' +
  154. '<div class="image-close">X</div>' +
  155. '<img>' +
  156. '<div class="info">' + file.name + '</div>' +
  157. '</div>'
  158. ),
  159. $img = $li.find('img');
  160. imgList.prepend($li);
  161. $(".image-close").on('click', function() {
  162. event.stopPropagation();
  163. $(this).parent().remove();
  164. uploader.removeFile(file);
  165. helper.methods.delImgs($(this).parent().attr("data-filesmallurl"), $(this).parent().attr("data-fileurl"));
  166. file_num(cindex)
  167. });
  168. });
  169. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  170. uploader.on('uploadSuccess', function(file, response) {
  171. $.each(response.data, function(i, j) {
  172. // obj=
  173. var $img = $('#' + cindex + file.id).find('img');
  174. $('#' + cindex + file.id).attr({
  175. 'data-filename': j.filename,
  176. 'data-fileext': j.fileext,
  177. 'data-filemd5': j.filemd5,
  178. 'data-filesize': j.filesize,
  179. 'data-fileurl': j.fileurl,
  180. 'data-filesmallurl': j.filesmallurl
  181. });
  182. uploader.makeThumb(file, function(error, src) {
  183. $img.attr('src', j.filesmallurl);
  184. $img.addClass('image-item');
  185. }, 50, 50);
  186. });
  187. $('#' + cindex + file.id).addClass('upload-state-done');
  188. file_num(cindex)
  189. });
  190. // 文件上传失败,现实上传出错。
  191. uploader.on('uploadError', function(file) {
  192. var $li = $('#' + cindex + file.id),
  193. $error = $li.find('div.error');
  194. // 避免重复创建
  195. if (!$error.length) {
  196. $error = $('<div class="error"></div>').appendTo($li);
  197. }
  198. $error.text('上传失败');
  199. });
  200. // 完成上传完了,成功或者失败,先删除进度条。
  201. // uploader.on('uploadComplete', function(file) {
  202. // });
  203. }
  204. //隐藏域值
  205. function file_num(num) {
  206. var arr = [];
  207. $('#image_list' + num).find('.thumbnail').each(function(j, m) {
  208. var obj = {
  209. 'filename': $(m).attr("data-filename"),
  210. 'fileext': $(m).attr("data-fileext"),
  211. 'filemd5': $(m).attr("data-filemd5"),
  212. 'filesize': $(m).attr("data-filesize"),
  213. 'fileurl': $(m).attr("data-fileurl"),
  214. 'filesmallurl': $(m).attr("data-filesmallurl")
  215. }
  216. arr.push(obj)
  217. })
  218. window['imageArr' + num] = arr;
  219. }
  220. //自定义字段 数组
  221. function getExtenArr() {
  222. var extenArr = [];
  223. $('.greetings_remarks span').each(function(g, h) {
  224. if ($(h).hasClass('active')) {
  225. extenArr.push($(h).text());
  226. }
  227. })
  228. return extenArr;
  229. }