| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- /**
- * 评价配送工单
- */
- var starNum = 5; //默认是 1 星
- var code = helper.request.queryString("code");
- var edit_id = helper.request.queryString("edit_id");
- var imageArr1 = '';
- $(document).ready(function() {
- autosize($('textarea'));
- $('#woCode').text(code);
- uploaderImg(1);
- //1 差、2 不满意、3 一般、4 满意、5 很满意
- rating.init('#ratingScores', {
- mode: 'LightEntire',
- num: 5,
- readOnly: false,
- select: function(num, total) {
- var self = this;
- layer.tips($(self).attr('title'), '#ratingTips');
- // console.log(this);
- // $('#ratingTips').text($(this).attr('title'));
- // console.log('当前第' + num + '颗,一共' + total + '颗。');
- },
- chosen: function(num, total) {
- //console.log('当前点击的是第' + num + '颗,一共' + total + '颗。');
- //rating.init('#rating1','unbindEvent');//只能选择一次
- starNum = num;
- layer.closeAll();
- $('#ratingTips').text($(this).attr('title'));
- },
- });
- $('.greetings_remarks span').click(function() {
- $(this).toggleClass('active');
- });
-
- $('#save_btns').on('click', btn_save);
- });
- //评价
- function btn_save() {
- $.ajax({
- type: 'post',
- url: huayi.config.callcenter_url + 'distributionapi/api/DistriWorkOrder/evaluate',
- dataType: 'json',
- async: true,
- beforeSend: function() { //触发ajax请求开始时执行
- $('#save_btns').attr("disabled", true);
- $('#save_btns').text('评价中...');
- loadIndex = layer.load();
- },
- data: {
- id: edit_id, //是 string 配送工单id
- wocode: code, // 是 string 配送工单code
- star: starNum, // 是 int 星级 服务满意度打分☆☆☆☆☆ 注:其中默认都是5星,最低只能打1星,每一星对应20分,合计100分
- evaluate: $('#evaluate').val(), // 是 string 评价
- label: getExtenArr(), // 是 List<string> 评价标签
- files: imageArr1, // 是 List<FileBaseModel> 附件
- channel: 1, // 是 int 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信 默认1
- },
- success: function(data) {
- layer.close(loadIndex);
- if (data.state === "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.$('#table_all').bootstrapTable('refresh');
- parent.layer.msg("评价成功");
- } else {
- $('#save_btns').attr("disabled", false);
- $('#save_btns').text('评价');
- }
- },
- error: function(textStatus) {
- layer.close(loadIndex);
- layer.confirm('网络繁忙,请稍后再试...', {
- icon: 7,
- closeBtn: 0,
- btn: ['确定'] //按钮
- });
- $('#save_btns').attr("disabled", false);
- $('#save_btns').text('评价');
- },
- complete: function(XMLHttpRequest, textStatus) {
- layer.close(loadIndex);
- if (textStatus == 'timeout') {
- var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
- xmlhttp.abort();
- layer.confirm('网络超时,请稍后再试...', {
- icon: 7,
- closeBtn: 0,
- btn: ['确定'] //按钮
- });
- }
- $('#save_btns').attr("disabled", false);
- $('#save_btns').text('评价');
- },
- });
- }
- //添加图片
- function uploaderImg(cindex) {
- var imgList = $('#image_list' + cindex),
- eleId = $('#filePicker' + cindex),
- uploader;
- uploader = WebUploader.create({
- // 自动上传。
- auto: true,
- // swf文件路径
- swf: '../../../js/Uploader.swf',
- // 文件接收服务端。
- server: huayi.config.callcenter_url + 'fileserverapi/Api/Upload',
- // 选择文件的按钮。可选。
- // 内部根据当前运行是创建,可能是input元素,也可能是flash.
- pick: eleId,
- // 图片数量限制
- // fileNumLimit: 4,
- //可以重复上传
- duplicate: true,
- formData: {
- uploadtype: 'evaluateDeliveryOrder' //自定义文件夹用于存放图片
- },
- // 只允许选择文件,可选。
- accept: {
- title: 'Images',
- extensions: 'gif,jpg,jpeg,bmp,png',
- mimeTypes: 'image/*'
- },
- fileSizeLimit: 30 * 1024 * 1024, // 30 M
- fileSingleSizeLimit: 5 * 1024 * 1024, // 5 M
- resize: false
- });
- //上传图片提示
- uploader.on('error', function(handler) {
- switch (code) {
- case "Q_EXCEED_NUM_LIMIT":
- layer.msg('只能上传六个文件。');
- break;
- case "Q_TYPE_DENIED":
- layer.msg('图片类型不正确。');
- break;
- case "F_DUPLICATE":
- layer.msg('该文件已上传,请选择其它文件。');
- break;
- case "F_EXCEED_SIZE":
- layer.msg('单文件大小不能超过5M。');
- break;
- case "Q_EXCEED_SIZE_LIMIT":
- layer.msg('总文件大小不能超过30M。');
- break;
- default:
- break;
- }
- });
- // 当有文件添加进来的时候
- uploader.on('fileQueued', function(file) {
- var $li = $(
- '<div id="' + cindex + '' + file.id + '" class="file-item thumbnail">' +
- '<div class="image-close">X</div>' +
- '<img>' +
- '<div class="info">' + file.name + '</div>' +
- '</div>'
- ),
- $img = $li.find('img');
- imgList.prepend($li);
- $(".image-close").on('click', function() {
- event.stopPropagation();
- $(this).parent().remove();
- uploader.removeFile(file);
- helper.methods.delImgs($(this).parent().attr("data-filesmallurl"), $(this).parent().attr("data-fileurl"));
- file_num(cindex)
- });
- });
- // 文件上传成功,给item添加成功class, 用样式标记上传成功。
- uploader.on('uploadSuccess', function(file, response) {
- $.each(response.data, function(i, j) {
- // obj=
- var $img = $('#' + cindex + file.id).find('img');
- $('#' + cindex + file.id).attr({
- 'data-filename': j.filename,
- 'data-fileext': j.fileext,
- 'data-filemd5': j.filemd5,
- 'data-filesize': j.filesize,
- 'data-fileurl': j.fileurl,
- 'data-filesmallurl': j.filesmallurl
- });
- uploader.makeThumb(file, function(error, src) {
- $img.attr('src', j.filesmallurl);
- $img.addClass('image-item');
- }, 50, 50);
- });
- $('#' + cindex + file.id).addClass('upload-state-done');
- file_num(cindex)
- });
- // 文件上传失败,现实上传出错。
- uploader.on('uploadError', function(file) {
- var $li = $('#' + cindex + file.id),
- $error = $li.find('div.error');
- // 避免重复创建
- if (!$error.length) {
- $error = $('<div class="error"></div>').appendTo($li);
- }
- $error.text('上传失败');
- });
- // 完成上传完了,成功或者失败,先删除进度条。
- // uploader.on('uploadComplete', function(file) {
- // });
- }
- //隐藏域值
- function file_num(num) {
- var arr = [];
- $('#image_list' + num).find('.thumbnail').each(function(j, m) {
- var obj = {
- 'filename': $(m).attr("data-filename"),
- 'fileext': $(m).attr("data-fileext"),
- 'filemd5': $(m).attr("data-filemd5"),
- 'filesize': $(m).attr("data-filesize"),
- 'fileurl': $(m).attr("data-fileurl"),
- 'filesmallurl': $(m).attr("data-filesmallurl")
- }
- arr.push(obj)
- })
- window['imageArr' + num] = arr;
- }
- //自定义字段 数组
- function getExtenArr() {
- var extenArr = [];
- $('.greetings_remarks span').each(function(g, h) {
- if ($(h).hasClass('active')) {
- extenArr.push($(h).text());
- }
- })
- return extenArr;
- }
|