| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- /**
- * 配送工单
- * */
- var stateVal = ''; //0-当天;1-本周;2-本月;3-本年;4-累计
- $(function() {
- //项目下拉
- helper.getDropList.getProlistDrop($('#sc_pro'));
- laydate.render({
- elem: '#sc_times',
- range: '~',
- theme: '#249fea',
- });
- initTable();
- //搜索
- $("#sc_btns").click(function() {
- initTable();
- });
- $('#sc_statebtn').find('input[type="radio"]').on('change', function() {
- stateVal = $(this).val();
- initTable();
- });
- });
- function initTable() {
- //先销毁表格
- $('#table_all').bootstrapTable('destroy');
- //初始化表格,动态从服务器加载数据
- $('#table_all').bootstrapTable({
- method: "get", //使用get请求到服务器获取数据
- url: huayi.config.callcenter_url + "distributionapi/api/DistriWorkOrder/getlistbypage", //获取数据的Servlet地址
- contentType: "application/x-www-form-urlencoded",
- striped: true, //表格显示条纹
- pagination: true, //启动分页
- pageSize: 10, //每页显示的记录数
- pageNumber: 1, //当前第几页
- pageList: [10, 20, 50, 100], //记录数可选列表
- search: false, //是否启用查询
- showColumns: false, //显示下拉框勾选要显示的列
- showRefresh: false, //显示刷新按钮
- sidePagination: "server", //表示服务端请求
- //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
- //设置为limit可以获取limit, offset, search, sort, order
- queryParamsType: "undefined",
- queryParams: function queryParams(params) { //设置查询参数
- var param = {
- pageindex: params.pageNumber, //否 int 页码
- pagesize: params.pageSize, //否 int 条数
- projectid: $('#sc_pro').val(), // 否 string 项目id
- keyword: $('#sc_key').val(), // 否 string 模糊查询
- wosorts: $('#sc_wosorts').val(), // 否 int 工单分类(1随机工单,2计划工单,-1所有 )
- wostate: $('#sc_wostate').val(), // 否 int 配送工单状态:0创建工单,1转派或者接收(待取货),2已取货(配送中),3货物异常(异常),4已完结/待评价,5已取消,6挂起 ,9已评价 -1所有
- stime: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[0], // 否 string 开始时间,“2018-03-27”
- etime: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[1], // 否 string 结束时间,“2018-03-27”
- datetype: stateVal, // 否 int 0-当天;1-本周;2-本月;3-本年;4-累计
- };
- return param;
- },
- responseHandler: function(res) {
- return {
- "total": res.data && res.data.total, //总页数
- "rows": res.data && res.data.rows,
- }
- },
- onLoadSuccess: function() { //加载成功时执行
- //layer.msg("加载成功");
- $('.tool_down').authorizeOperateButton();
- },
- onLoadError: function() { //加载失败时执行
- //layer.msg("加载数据失败", { time: 1500, icon: 2 });
- }
- });
- }
- //格式化 操作
- function formatterOperate(val, row) {
- //int 0新工单,1转派或者接收(待取货),2已取货(配送中),3货物异常(异常) 4已完结/待评价,5已取消,6挂起 ,9已评价
- var str = '<div class="task_tools" onclick = helper.methods.taskTools(this)>' +
- '<a title="操作"><i class="fa fa-cogs" aria-hidden="true"></i></a>' +
- '<ul class="tool_down">' +
- '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id +
- '\')"><i class="fa icon-detail tub"></i>详情</a><li>';
- if (row.wostate === 0) {
- str += '<li><a class="aBtn" authorize="yes" id="HY_edit_' + row.id + '" onclick="btn_edit(\'' + row.id +
- '\')"><i class="fa icon-edit tub"></i>编辑</a><li>' +
- '<li><a class="aBtn" authorize="yes" id="HY_transfer_' + row.id + '" onclick="btn_transfer(\'' + row.id + ',' + row.projectid +
- ',' + row.wocode + '\')"><i class="fa icon-transfer tub"></i>转派</a><li>';
- }
- if (row.wostate < 2) {
- str += '<li><a class="aBtn" authorize="yes" id="HY_cancel_' + row.id + '" onclick="btn_cancel(\'' + row.id +
- '\')"><i class="fa icon-lixian1 tub"></i>取消</a><li>' +
- '<li><a class="aBtn" authorize="yes" id="HY_hangup_' + row.id + '" onclick="btn_hangup(\'' + row.id +
- '\')"><i class="fa icon-manglu tub"></i>挂起</a><li>';
- }
- if (row.wostate === 4 && row.sended === 0) {
- str += '<li><a class="aBtn" authorize="yes" id="HY_evaluate_' + row.id + '" onclick="btn_evaluate(\'' + row.id +
- '\', \'' + row.wocode + '\')"><i class="fa icon-zan tub"></i>评价</a><li>';
- }
- if(row.isoffence === 1 && row.content_offence != '' && row.isaudit_offence <= 0){
- str += '<li><a class="aBtn" authorize="yes" id="HY_audit_' + row.id + '" onclick="btn_audit(\'' + row.id + '\',\''+ row.content_offence +'\')"><i class="fa icon-msnui-audit tub"></i>审核</a><li>';
- }
- str += '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id +
- '\')"><i class="fa icon-delete tub"></i>删除</a><li>' +
- '</ul></div>'
- return str;
- }
- //格式化 工单状态
- function formatterwostate(val, row) {
- //int 0新工单,1转派或者接收(待取货),2已取货(配送中),3货物异常(异常) 4已完结/待评价,5已取消,6挂起 ,9已评价
- var stateClass, stateName;
- switch (val) {
- case 0:
- stateClass = 'state_audit_wait';
- stateName = '新工单';
- break;
- case 1:
- stateClass = 'state_audit_refuse';
- stateName = '待取货';
- break;
- case 2:
- stateClass = 'state_audit_doned';
- stateName = '配送中';
- break;
- case 3:
- stateClass = 'state_audit_refuse';
- stateName = '货物异常';
- break;
- case 4:
- if (row.sended === 1) {
- stateClass = 'state_audit_termination';
- stateName = '异常完结';
- } else {
- stateClass = 'state_audit_done';
- stateName = '已完结';
- }
- break;
- case 5:
- stateClass = 'state_audit_revoke';
- stateName = '已取消';
- break;
- case 6:
- stateClass = 'state_audit_hang';
- stateName = '已挂起';
- break;
- case 9:
- stateClass = 'state_audit_other';
- stateName = '已评价';
- break;
- default:
- stateClass = 'text-block';
- stateName = '-';
- break;
- }
- return '<a class="state_audit ' + stateClass + '" href="javascript:;">' + stateName + '</a>';
- }
- //格式化 工单类型
- function formatterwosorts(val, row) {
- var stateTxt = '-';
- switch (val) {
- case 1:
- stateTxt = '随机';
- break;
- case 2:
- stateTxt = '分送';
- break;
- default:
- break;
- }
- return '<span>' + stateTxt + '</span>';
- }
- //格式化 紧急程度
- function formatterEmergencyid(val, row) {
- var stateClass = 'timeout_default';
- var stateTxt = '-';
- switch (val) {
- case 1:
- stateClass = 'timeout_success';
- stateTxt = '一般';
- break;
- case 2:
- stateClass = 'timeout_termination';
- stateTxt = '紧急';
- break;
- default:
- break;
- }
- return '<span class="' + stateClass + '">' + stateTxt + '</span>';
- }
- //格式化 工单编号
- function formatterWocode(val, row) {
- var str = '-';
- var etext = '';
- if (row.isoffence === 1) {
- etext = '违规';
- //isaudit_offence int 违规是否审核通过 0无操作 1不通过 2通过
- if (row.content_offence != '' && row.isaudit_offence <= 0) {
- etext = '违规(已申诉)'; //需要审核
- }
- if (row.content_offence != '' && row.isaudit_offence === 1) {
- etext = '违规(未通过)'; //已审核 未通过
- }
- }
- // if (row.sended === 1) {
- // etext = '异常';
- // }
- str = '<span class="deliver_wocode">' + val +
- '<b>' + etext + '</b>' +
- '</span>';
- return str;
- }
- //格式化 物品名称
- function formatterGoodslist(val, row) {
- if (val && val.length > 1) {
- return val[0].goodsname + '(' + val[0].num + ')...';
- } else if (val && val.length === 1 && val[0] != "") {
- return val[0].goodsname + '(' + val[0].num + ')';
- } else {
- return '-';
- }
- }
- //格式化 内容
- function formatterContent(val, row) {
- if (val) {
- var codeContent = decodeURIComponent(val);
- codeContent = helper.filter.delHtmlTag(codeContent);
- codeContent = $.trim(codeContent);
- var cc = codeContent.length > 20 ? codeContent.substr(0, 20) + '...' : codeContent;
- return '<div title="' + codeContent + '">' + cc + '</div>';
- } else {
- return '-';
- }
- }
- //格式化 地址
- function formatterAddress(val, row) {
- if (val && val.length > 0) {
- return val[0].building_name + val[0].floor_name + val[0].department_name;
- } else {
- return '-';
- }
- }
- //格式化 渠道来源
- function formatterChannel(val, row) {
- //1表示PC 2表示安卓 3表示IOS 4表示微信
- var str = '-';
- switch (val) {
- case 1:
- str = 'PC';
- break;
- case 2:
- str = '安卓';
- break;
- case 3:
- str = 'IOS';
- break;
- case 4:
- str = '微信';
- break;
- default:
- break;
- }
- return str;
- }
- //格式化 时间
- function formatterCheckTime(val) {
- if (val == "0001-01-01 00:00:00" || val == "" || val == null || val == undefined) {
- return "-";
- } else {
- return val;
- }
- }
- //格式化创建人
- function formatterName(val, row){
- var str = '';
- if(row.channel === 4){
- str = row.createname;
- }else{
- str = val + '-' + row.createname;
- }
- return str;
- }
- //查看 详情
- function btn_details(edit_id) {
- layer.open({
- type: 2,
- content: "template/seeDeliveryOrderDetails.html?edit_id=" + edit_id, //iframe的url,no代表不显示滚动条
- title: '查看配送工单',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
- //取消
- function btn_cancel(edit_id) {
- layer.confirm('您确定要将当前配送工单取消吗?', {
- icon: 7,
- btn: ['确定', '取消'] //按钮
- }, function() {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "distributionapi/api/DistriWorkOrder/cancel",
- dataType: 'json',
- data: {
- id: edit_id, // 是 string 配送工单id
- channel: 1 // 是 int 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信 默认1
- },
- async: true,
- success: function(data) {
- layer.msg("取消成功!");
- $('#table_all').bootstrapTable('refresh');
- }
- });
- });
- }
- //挂起
- function btn_hangup(edit_id) {
- layer.confirm('您确定要将当前配送工单挂起吗?', {
- icon: 7,
- btn: ['确定', '取消'] //按钮
- }, function() {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "distributionapi/api/DistriWorkOrder/hangup",
- dataType: 'json',
- data: {
- id: edit_id, // 是 string 配送工单id
- channel: 1 // 是 int 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信 默认1
- },
- async: true,
- success: function(data) {
- layer.msg("挂起成功!");
- $('#table_all').bootstrapTable('refresh');
- }
- });
- });
- }
- //评价
- function btn_evaluate(edit_id, code) {
- layer.open({
- type: 2,
- content: "template/evaluateDeliveryOrder.html?edit_id=" + edit_id + "&code=" + code, //iframe的url,no代表不显示滚动条
- title: '评价配送工单',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
- //添加
- function btn_add() {
- isEvaluation().then(function(res) {
- if (res.state.toLowerCase() === "success") {
- layer.open({
- type: 2,
- content: "template/addOrEditDeliveryOrder.html", //iframe的url,no代表不显示滚动条
- title: '添加配送工单',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
- });
- }
- //编辑
- function btn_edit(edit_id) {
- layer.open({
- type: 2,
- content: "template/addOrEditDeliveryOrder.html?edit_id=" + edit_id, //iframe的url,no代表不显示滚动条
- title: '编辑配送工单',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
- //批量删除
- function btn_deletes() {
- var ids = $.map($('#table_all').bootstrapTable('getSelections'),
- function(row) {
- return row.id;
- });
- /*判断长度*/
- if (ids.length <= 0) {
- layer.confirm('请选择要删除的选项', {
- icon: 7,
- btn: ['确定'] //按钮
- });
- return;
- }
- btn_delete(ids);
- }
- //删除
- function btn_delete(del_id) {
- /*发送请求*/
- layer.confirm('您确定要删除当前配送工单吗?', {
- icon: 7,
- btn: ['确定', '取消'],
- yes: function(index, layero) {
- $.post(huayi.config.callcenter_url + "distributionapi/api/DistriWorkOrder/delete", {
- ids: del_id,
- channel: 1,
- }, function(result) {
- result = JSON.parse(result);
- if (result.state.toLowerCase() == "success") {
- layer.msg("删除成功");
- $('#table_all').bootstrapTable('refresh');
- }
- })
- },
- });
- }
- //是否有未完成的评价
- function isEvaluation() {
- var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
- $.post(huayi.config.callcenter_url + "distributionapi/api/DistriWorkOrder/isevaluation", {}, function(result) {
- result = JSON.parse(result);
- dtd.resolve(result); // 改变Deferred对象的执行状态
- });
- return dtd.promise(); // 返回promise对象
- }
- //批量转派
- function btn_transfers() {
- var wostates = $.map($('#table_all').bootstrapTable('getSelections'),
- function(row) {
- return row.wostate;
- });
- if (wostates.length <= 0) {
- layer.confirm('请选择要转派的工单', {
- icon: 7,
- btn: ['确定'] //按钮
- });
- return;
- }
- if (wostates.length >= 100) {
- layer.confirm('批量转派一次最多转派100个工单。', {
- icon: 7,
- btn: ['确定'] //按钮
- });
- return;
- }
- for (var i = 0; i < wostates.length; i++) {
- if (wostates[i] != 0) {
- console.count();
- layer.confirm('请确认您选择的工单是否是新工单,只有新工单可以转派!', {
- icon: 7,
- btn: ['确定'] //按钮
- });
- return;
- }
- }
- var ids = $.map($('#table_all').bootstrapTable('getSelections'),
- function(row) {
- return row.id + ',' + row.projectid + '|';
- });
- btn_transfer(ids);
- }
- //转派
- function btn_transfer(edit_id) {
- layer.open({
- type: 2,
- content: "template/transferDeliveryOrder.html?edit_id=" + encodeURIComponent(edit_id), //iframe的url,no代表不显示滚动条
- title: '转派配送工单',
- resize: false,
- area: ['50%', '60%'], //宽高
- });
- }
- //审核违规申诉
- function btn_audit(ids, content_offence) {
- var IsAudit = 1; //1不通过 2通过 默认不通过1
- layer.confirm('违规原因:<br/>' + content_offence, {
- title: '是否通过审核?',
- btn: ['通过', '拒绝'],
- }, function(index, layero) {
- //通过
- var value = '';
- IsAudit = 2;
- auditProject(ids, IsAudit, value);
- }, function(index) {
- //拒绝
- IsAudit = 1;
- layer.prompt({
- formType: 2,
- //value: '初始值',
- title: '请输入拒绝的原因',
- area: ['600px', '200px'] //自定义文本域宽高
- }, function(value, index, elem) {
- auditProject(ids, IsAudit, value);
- layer.close(index);
- });
- });
- }
- //审核
- function auditProject(ids, IsAudit, IsAuditNote) {
- $.post(huayi.config.callcenter_url + "distributionapi/api/DistriWorkOrder/auditoffence", {
- id: ids, // 是 string 配送工单id
- isaudit: IsAudit, // 是 int 是否审核通过 1不通过 2通过 默认不通过1
- content: IsAuditNote, // 是 string 驳回原因
- channel: 1, // 是 int 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信 默认1
- }, function(data) {
- data = JSON.parse(data);
- if (data.state.toLowerCase() === "success") {
- $('#table_all').bootstrapTable('refresh');
- layer.msg("审核成功");
- }
- });
- }
|